* Re: any users of Fiber concurrency?
[not found] ` <20130830004541.GA14964-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
@ 2013-09-05 18:44 ` Lin Jen-Shin (godfat)
0 siblings, 0 replies; 2+ messages in thread
From: Lin Jen-Shin (godfat) @ 2013-09-05 18:44 UTC (permalink / raw)
To: Rainbows! list
On Fri, Aug 30, 2013 at 8:45 AM, Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org> wrote:
> Just curious what your experiences are, if any...
>
> I ask because I just realized I haven't used Fibers in several years,
> now... (Both inside and outside of Rack servers)
>
> I think there was a lot of excitement over them when 1.9 came out, but
> we mostly realized it was too hard to get existing libraries to use
> them...
We once used it on production, but now turned to using threads.
I still like the idea, however as you said, most of the existing
libraries are not aware of them. Patching them one by one might
be a solution, but that could be a lot of works, depending on how
many libraries we're using.
Interestingly, although we ran it for a while, and we didn't see many
errors, it shouldn't really work correctly. I realized this after examining
ActiveRecord's source. It is aware of threads, but not fibers, so I
think we're actually using the same connection in different fibers.
After switching to threads, we no longer saw some weird connection
errors.
Although Thread#[] would be treated as fibers local instead of threads
local, ActiveRecord is using Thread.current.object_id as the connection
id, so it's still local to current thread.
On the other hand, before Ruby 2.0, we can't even access threads local
inside a non-root fiber, since Thread#[] would be fiber local...
Now we have Thread.current.thread_variable_get and friends.
We don't have Fiber.root, either.
I feel fibers in Ruby are not complete, and might never be.
Also, as far as I know, celluloid is using fibers internally as well.
However, it's easy to hit stack limit on fibers in Ruby 1.9... so
there's also an equivalent implementation using threads.
Again, I still like the idea, but I feel it might not be too realistic to
use them in Ruby right now...
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying
^ permalink raw reply [flat|nested] 2+ messages in thread