From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 60C3B1F4B4 for ; Mon, 1 Feb 2021 17:14:05 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D9C34120B0C; Tue, 2 Feb 2021 02:13:09 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 4884C120B0C for ; Tue, 2 Feb 2021 02:13:08 +0900 (JST) Received: by filterdrecv-p3las1-598b7f99cd-7tg8x with SMTP id filterdrecv-p3las1-598b7f99cd-7tg8x-19-601836D5-99 2021-02-01 17:13:57.986585078 +0000 UTC m=+322819.048018951 Received: from herokuapp.com (unknown) by ismtpd0124p1mdw1.sendgrid.net (SG) with ESMTP id dTFopaEZRHKj2ZZDL9JC3Q for ; Mon, 01 Feb 2021 17:13:57.839 +0000 (UTC) Date: Mon, 01 Feb 2021 17:13:58 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 78282 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17592 X-Redmine-Issue-Author: marcandre X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: Eregon 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-SG-EID: =?us-ascii?Q?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr0vNFlKgo=2Fa9zsfgJX0C1?= =?us-ascii?Q?h5fqoynaQpPuyxCoULVbFotujOEJ16DEGdKm43d?= =?us-ascii?Q?vT83u+WPUwlEtMY4B4ynJ=2FV7l+5dm9pvMpxh3l+?= =?us-ascii?Q?XKXTeMcCIgXS4gtIJrFNIeQ3P8BCF3c4SboSzun?= =?us-ascii?Q?a3JVMOd9g2ybLIQJead9XPl0EfT8t95zzMUyqhN?= =?us-ascii?Q?bXTpqVsh5TmD12jDY=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102365 Subject: [ruby-core:102365] [Ruby master Feature#17592] Ractor should allowing reading shareable class instance variables 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" Issue #17592 has been updated by Eregon (Benoit Daloze). For simplicity, I think it's probably best to disallow reassigning in non-main Ractors. It could be allowed though, as long as the value is shareable, then all other Ractors would notice the new value. Reassigning in main Ractor should be allowed, and then raise when trying to read a non-shareable values from other Ractors. i.e., the semantics of the main Ractor should not change whether there is only the main Ractor or multiple Ractors. ---------------------------------------- Feature #17592: Ractor should allowing reading shareable class instance variables https://bugs.ruby-lang.org/issues/17592#change-90226 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Assignee: ko1 (Koichi Sasada) ---------------------------------------- It would be very helpful if Ractor was allowing reading class instance variables from non-main Ractor. Currently is raises an IsolationError: ```ruby module Foo singleton_class.attr_accessor :config Foo.config = {example: 42}.freeze end Ractor.new { p Foo.config } # => IsolationError ``` This limitation makes it challenging to have an efficient way to store general configs, i.e. global data that mutated a few times when resources get loaded but it immutable afterwards, and needs to be read all the time. Currently the only way to do this is to use a constant and use `remove_const` + `const_set` (which can not be made atomic easily). I think that allowing reading only may be the best solution to avoid any race condition, e.g. two different Ractors that call `@counter += 1`. The only 3 scenarios I see here are: 0) declare the constant hack the official way to store config-style data 1) allow reading of instance variables for shareable objects (as long as the data is shareable) 2) allow read-write I prefer 1) -- https://bugs.ruby-lang.org/