Rainbows! Rack HTTP server user/dev discussion
 help / color / Atom feed
From: "Lin Jen-Shin (godfat)" <godfat-hOE/xeEBYYIdnm+yROfE0A@public.gmane.org>
To: "Rainbows! list" <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Subject: Re: any users of Fiber concurrency?
Date: Fri, 6 Sep 2013 02:44:40 +0800
Message-ID: <CAA2_N1ssxvdJNjs_u8cRhGZjnQH2yyDA-ZQwQGp_C+a-zyQTmQ@mail.gmail.com> (raw)
In-Reply-To: <20130830004541.GA14964-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>

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

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
Do not quote signatures (like this one) or top post when replying

      parent reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30  0:45 Eric Wong
     [not found] ` <20130830004541.GA14964-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2013-09-05 18:44   ` Lin Jen-Shin (godfat) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://yhbt.net/rainbows/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA2_N1ssxvdJNjs_u8cRhGZjnQH2yyDA-ZQwQGp_C+a-zyQTmQ@mail.gmail.com \
    --to=godfat-hoe/xeebyyidnm+yrofe0a@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Rainbows! Rack HTTP server user/dev discussion

Archives are clonable:
	git clone --mirror https://yhbt.net/rainbows-public
	git clone --mirror http://ou63pmih66umazou.onion/rainbows-public

Example config snippet for mirrors

Newsgroups are available over NNTP:

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git