From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 64BD81F5CB for ; Thu, 3 Oct 2024 04:43:42 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=seMC32FJ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=J8iBBWmh; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1727930620; bh=aY1PyUdrVNEdINWuCajErwhVdYPHQHo0HqwlbJiu+zk=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=seMC32FJ/V0MVDQY20/BxVPPuSiqIs3SA9iYF9Ssl42ksfVlI8lkIE+7vuz1oKO/c zlx+OJQMXfACv8xniHrcWcAaaUxZnN1B+6f1zKAeMZKHTgF9G9X9/vj0uFET480GBw 5yJ09kRWv4OMc/iEQBiPrlwGrdIPiddihRiLC5hM= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 4380143F6D for ; Thu, 3 Oct 2024 04:43:40 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=J8iBBWmh; dkim-atps=neutral Received: from s.wrqvtbkv.outbound-mail.sendgrid.net (s.wrqvtbkv.outbound-mail.sendgrid.net [149.72.123.24]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 329D643EF3 for ; Thu, 3 Oct 2024 04:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=I5lrQKr1oPr0oYm1iBkifVXttfcEFE8bhStQuyzSvgo=; b=J8iBBWmh712r23nMVQZN0RuOBAe19sPb3GE8i/VLdV8Eh922biSPqSYleq1IEnWXbNMS OLrp3VxM3E/nvZ8vU8yW+w/q0FVNDOTB7UfqZlve5kFcXOHnuRpaAOeO1b3ph/UcXhSPiS A834Q3YM5TqMBPwIT/1Bva5yhAdQo+H+KcPASfUTyjD+CCJbG045kbLi0dSB6QxaNw2hUq nefMu8iyUFoiH3SbBZplNCYOUiYd625Qclj3GxxFLbeWxPrcdoioMKUewnQ3DKrifHqTzq fWHZxjQZnwApGGuC5KqPK11aqUyFXyarcycqdlojojRIBLOoKNnptCaeTMReI/gA== Received: by recvd-55fc7fd858-j99zt with SMTP id recvd-55fc7fd858-j99zt-1-66FE20EF-3 2024-10-03 04:43:27.126978881 +0000 UTC m=+1766854.634848033 Received: from herokuapp.com (unknown) by geopod-ismtpd-34 (SG) with ESMTP id ZOb3qfo5S12psEdEVMwwMw for ; Thu, 03 Oct 2024 04:43:27.063 +0000 (UTC) Date: Thu, 03 Oct 2024 04:43:27 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 20750 X-Redmine-Issue-Author: kbrock X-Redmine-Issue-Priority: Normal X-Redmine-Sender: matz X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 96053 X-SG-EID: =?us-ascii?Q?u001=2Eqca74XLbbBG2T0HhbEZgBN9E1Qhb0c7bGBe1waNAWdTreSqyWPDekZUgq?= =?us-ascii?Q?NYk4+nm=2F0VIqwc8ZBTQxqk7G=2FctsRLtYG2yTl=2FP?= =?us-ascii?Q?2CaGNETxG2Syki0d66ljOHvgOVxV2saA4KVJ=2FRR?= =?us-ascii?Q?7vaJVHFXcs7Qisrv=2FzON7XW=2FHd0WdjAD+WFvb5T?= =?us-ascii?Q?9Dg8ddbXsm=2F8BA4MreRzJ6TPjFo0vL5A0lwnq3e?= =?us-ascii?Q?SY+YdbRiheCJyv5LYcbpgZYU1178pYLOpgESGMV?= =?us-ascii?Q?kH3SY411P6gi57jpbpUZ7EwvLQ=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: HRRYGWWPSHM234UICQLAWVYZWQHWEDHI X-Message-ID-Hash: HRRYGWWPSHM234UICQLAWVYZWQHWEDHI X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:119416] [Ruby master Feature#20750] Allow rb_thread_call_with_gvl to work when thread already has GVL List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "matz (Yukihiro Matsumoto) via ruby-core" Cc: "matz (Yukihiro Matsumoto)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20750 has been updated by matz (Yukihiro Matsumoto). OK, I accept to make `rb_thread_call_with_gvl` to acquire GVL only when needed. @ko1 worried it may encourage bad design pattern, but not allowing `rb_thread_call_with_gvl` with GVL does not improve the situation. So I accept it, you handle it with care. Matz. ---------------------------------------- Feature #20750: Allow rb_thread_call_with_gvl to work when thread already has GVL https://bugs.ruby-lang.org/issues/20750#change-110030 * Author: kbrock (Keenan Brock) * Status: Open ---------------------------------------- Hello All, I'm hoping we can make `ruby_thread_has_gvl_p` a public method and no longer experimental. I saw the following code in a gem that was not compiling with ruby 3.3: ``` c // int ruby_thread_has_gvl_p(void); // <== line of concern if (ruby_thread_has_gvl_p()) { method_call(&context); } else { rb_thread_call_with_gvl(method_call, &context); } ``` 400 unique projects on github added the line listed above to fix compilation. [1] Some of the projects detected the method first in `extconf.rb`, but a majority just referenced it. `ffi` used to have the detection code but dropped it since the method was in all supported ruby versions. It feels like this method is now part of the undocumented public interface. My suggestion is to add the method to the real public interface in `ruby/thread.h`. PR with possible solution: https://github.com/ruby/ruby/pull/11619 Also included a patch if that is easier Thank you for your consideration, Keenan Timeline: - Dec 30 2008 - `rb_thread_call_with_gvl` introduced via 9c04a06 [2] - Jan 12 2009 - `ruby_thread_has_gvl_p` introduced via 6f09fc2 [4] - Jul 18 2012 - `rb_thread_call_with_gvl` made public via e9a91d2 [3] Current references to code: `rb_thread_call_with_gvl` [5] `ruby_thread_has_gvl_p` [6]: [1]: https://github.com/search?q=ruby_thread_has_gvl_p+language%3AC++NOT+is%3Afork++NOT+is%3Aarchived&type=code [2]: https://github.com/ruby/ruby/commit/9c04a0647fb99f7554cb2e04385ddbb970631e02 [3]: https://github.com/ruby/ruby/commit/e9a91d2c95dfe22ad0487952f7a1053ef9a5fd16 [4]: https://github.com/ruby/ruby/commit/6f09fc2efd1915c4337ce6dded52a8a8771c3222 [5]: https://github.com/ruby/ruby/blob/master/thread.c#L1878 [6]: https://github.com/ruby/ruby/blob/master/thread.c#L1923 ---Files-------------------------------- 11618.patch (3.18 KB) 11649-lenent-rb_thread_call_with_gvl.patch (1.26 KB) 11649b-additional-changes.patch (2.91 KB) -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/