BT

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

| by Werner Schuster Follow 9 Followers on Sep 10, 2008. Estimated reading time: 1 minute |
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 Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT