From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS33070 50.56.128.0/17 X-Spam-Status: No, score=0.7 required=3.0 tests=AWL,MSGID_FROM_MTA_HEADER, RDNS_NONE shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: "Lin Jen-Shin (godfat)" Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: any users of Fiber concurrency? Date: Fri, 6 Sep 2013 02:44:40 +0800 Message-ID: References: <20130830004541.GA14964@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1378407271 21039 80.91.229.3 (5 Sep 2013 18:54:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Sep 2013 18:54:31 +0000 (UTC) To: "Rainbows! list" Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Thu Sep 05 20:54:35 2013 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=godfat.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ziwPBjw/PsZMYQqHGeEEQmJsiZUxnfZToj9VaZKCRx0=; b=LsqApyz6X8yaQi/hIp3MnyPomgTkVm3q1GENZzRvFUIFmQX1PmdNx2OlOEjwgBGEBf XvMdQmuvNYfyqUTC71kVppu1hlW3vTaCUO1ugpeBhMLWUyel1XVLL3mmVNtu/xZ49hC4 95WNShdHaTDQCerjiSB5PoGMtNVpCC5mY/SUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=ziwPBjw/PsZMYQqHGeEEQmJsiZUxnfZToj9VaZKCRx0=; b=IKN+SG8nhJ0hJYVL80ONPHCzsIpb8/pmTZf0sg7V3q6pgbaW+8z9243QiDIp3fuBoT CgeAb11JX0HaDgWZroxCIXc+gOFEHg6diVhR3dIu85IpMkeX01WmqbMcEJJmbPGg1dBU EgzlHtFUoFY+cqk1TmXdmTYD59BSCUhrro8BsoDDxOhb3ozrtpE5jucdvolFubmOjWyG f1vB6KttgwyS5hZCDDxfSpP1KFtusMFq8JXgef+wKm3gNt5XGP+adQP9WpCNozL06JzW Muzf9NCcD4aKlIfsdC/PesNN0N8p3q78+W4Qk249UakQejsxzXdq/HO06veKgvqdPRH6 cddg== X-Gm-Message-State: ALoCoQlgJQU7XPGip2U058RpAbuFQ+zT26fTTZShXQ8WyfPUYheryoiRrt1pAwvggODbGYArnGNh X-Received: by 10.14.214.136 with SMTP id c8mr15269889eep.6.1378406712116; Thu, 05 Sep 2013 11:45:12 -0700 (PDT) In-Reply-To: <20130830004541.GA14964-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org> X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Broken-Reverse-DNS: no host name found for IP address 50.56.192.79 Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:532 Archived-At: Received: from [50.56.192.79] (helo=rubyforge.org) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VHehN-0002kS-D4 for gclrrg-rainbows-talk@m.gmane.org; Thu, 05 Sep 2013 20:54:33 +0200 Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id E6A0E2E17D; Thu, 5 Sep 2013 18:54:32 +0000 (UTC) Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com [209.85.215.181]) by rubyforge.org (Postfix) with ESMTP id 321532E153 for ; Thu, 5 Sep 2013 18:45:14 +0000 (UTC) Received: by mail-ea0-f181.google.com with SMTP id d10so1096334eaj.26 for ; Thu, 05 Sep 2013 11:45:12 -0700 (PDT) Received: by 10.223.172.69 with HTTP; Thu, 5 Sep 2013 11:44:40 -0700 (PDT) On Fri, Aug 30, 2013 at 8:45 AM, Eric Wong 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