From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id ECE401F62D for ; Fri, 6 Jul 2018 21:11:58 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C912E120C2B; Sat, 7 Jul 2018 06:11:56 +0900 (JST) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1BEDB120C2B for ; Sat, 7 Jul 2018 06:11:52 +0900 (JST) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DCF791F62D; Fri, 6 Jul 2018 21:11:49 +0000 (UTC) Date: Fri, 6 Jul 2018 21:11:49 +0000 From: Eric Wong To: ruby-core@ruby-lang.org Message-ID: <20180706211149.aj3mkndkndrk2yjr@dcvr> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-ML-Name: ruby-core X-Mail-Count: 87840 Subject: [ruby-core:87840] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" funny.falcon@gmail.com wrote: > It is impossible to implement Thread migration between native > threads. All other is possible. It may be possible but we'd either lose performance and/or break C extensions. So it won't happen soon :) General update on this topic: I've been piggy-backing groundwork for this features into trunk as separate issues: * SIGCHLD-based rb_waitpid into trunk to fix a problem with MJIT and it finally appears stable across different platforms: https://bugs.ruby-lang.org/issues/14867 It also helped me understand some portability quirks and differences of non-Free platforms I don't use, so I will be able to workaround them more easily in the future. * Since many methods to be affected by green threads need timeout args, I'm working on implementing Timeout in the VM: https://bugs.ruby-lang.org/issues/14859 Green-threads versions of rb_wait_for_single_fd, rb_thread_sleep*, rb_thread_select, etc... will need to manage their own timeouts, anyways. * Queue+SizedQueue MUST work with this feature, as green thread need to communicate with each other. Same as "mailbox" or in actor model or pipes or whatever other languages call it. Groundwork for this was already laid in 2.5: https://bugs.ruby-lang.org/issues/13552 There will only be one API addition affecting green-thread creation. Right now, most likely candidates are: * Thread::Green.new {} # Just like Thread.new, but with "::Green" * Thread.green {} # 5 characters shorter than above * Thread.create(scheduler: ..., args:...) {} # maybe too verbose