From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.1 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id D6DF320D12 for ; Thu, 1 Jun 2017 00:37:11 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BAC0D120736; Thu, 1 Jun 2017 09:37:09 +0900 (JST) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by neon.ruby-lang.org (Postfix) with ESMTPS id 3963D120733 for ; Thu, 1 Jun 2017 09:36:59 +0900 (JST) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id AC12320D12; Thu, 1 Jun 2017 00:36:56 +0000 (UTC) Date: Thu, 1 Jun 2017 00:36:56 +0000 From: Eric Wong To: ruby-core@ruby-lang.org Message-ID: <20170601003656.GA12877@whir> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-ML-Name: ruby-core X-Mail-Count: 81493 Subject: [ruby-core:81493] 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" Pull request below for non-"git am" users... I tried my best to add many comments throughout the code. I realize this is a lot of new code; and not a typical or common usage of kqueue or epoll. The kqueue code ended up being very complicated to support corner cases (see comments in iom_kqueue); so perhaps the epoll implementation should be easiest-to-understand. I suggest understanding data structures, first; everything else will be easier. Please do not hesitate to ask here if you come across questions or bugs or any comments. Finally; libkqueue is broken (using epoll on Linux) for corner cases. I am using a FreeBSD 11.0 VM for kqueue development; but I may resume working with libkqueue upstream if I have time. I expect real-world Linux users to be using native epoll, of course; so no big problems, there. The following changes since commit d0015e4ac6b812ea1681b1f5fa86fbab52a58960: Improve performance of implicit type conversion (2017-05-31 12:30:57 +0000) are available in the git repository at: git://80x24.org/ruby iom for you to fetch changes up to 8d6b09d46fcdf6362d6f875347c4790d5cf86401: auto fiber schedule for rb_wait_for_single_fd and rb_waitpid (2017-06-01 00:07:18 +0000) ---------------------------------------------------------------- Eric Wong (1): auto fiber schedule for rb_wait_for_single_fd and rb_waitpid common.mk | 7 + configure.in | 32 ++ cont.c | 119 +++- include/ruby/io.h | 2 + iom.h | 92 ++++ iom_common.h | 198 +++++++ iom_epoll.h | 423 +++++++++++++++ iom_internal.h | 251 +++++++++ iom_kqueue.h | 600 +++++++++++++++++++++ iom_pingable_common.h | 46 ++ iom_select.h | 306 +++++++++++ prelude.rb | 12 + process.c | 14 +- signal.c | 40 +- .../wait_for_single_fd/test_wait_for_single_fd.rb | 44 ++ test/lib/leakchecker.rb | 9 + test/ruby/test_fiber_auto.rb | 238 ++++++++ thread.c | 42 ++ thread_pthread.c | 5 + vm.c | 9 + vm_core.h | 4 + 21 files changed, 2479 insertions(+), 14 deletions(-) create mode 100644 iom.h create mode 100644 iom_common.h create mode 100644 iom_epoll.h create mode 100644 iom_internal.h create mode 100644 iom_kqueue.h create mode 100644 iom_pingable_common.h create mode 100644 iom_select.h create mode 100644 test/ruby/test_fiber_auto.rb