BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Fibers Roundup: NeverBlock Now Rails Compatible, "Poor Man's" Fibers For 1.8

Fibers Roundup: NeverBlock Now Rails Compatible, "Poor Man's" Fibers For 1.8

This item in japanese

NeverBlock is a library using Ruby Fibers for asynchronous database access. Up until now, the use of Fibers meant that NeverBlock had to run on Ruby 1.9. A new release of NeverBlock solves the issue by using a backport the Fibers functionality. Aman Gupta recently published a Fiber implementation based on Ruby Threads called "Poor Man's Fibers" (the Fiber implementation in the NeverBlock Github repository).

Emulating Fibers with Threads uses more resources than real Fibers when it comes to memory use and scheduling overhead. However, NeverBlock pools Fibers anyway, which should limit the impact of using the backport. JRuby uses a similar (experimental) approach to providing Fibers (GitHub repository for JRuby's Fiber implementation) as part of it's Ruby 1.9 support. JRuby's Fibers implementation also maps every Fiber to a Thread and thus has similar performance characteristics to the "Poor Man's Fibers". Muhammed Ali, one of the creators of NeverBlock, looked at the cost of Fibers vs. the cost of Threads, which shows Ruby 1.9's Fibers to use up much less memory and take much less time to create.

Another feature of the new NeverBlock release is built-in support for Rails
An end to end seamless support for the Ruby on Rails framework. Adding support for Rails is as easy as modifying a line in your database.yml and adding 2 lines to your environment.rb file.
The linked post contains more information which lines to add for different servers and databases.

With Fibers getting a lot more attention, and Ruby 1.9.1 starting to stabilize, have you considered using Fibers?

Rate this Article

Adoption
Style

BT