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.7 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_HI,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 642571F9FD for ; Mon, 15 Feb 2021 16:50:07 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5D8C1120A49; Tue, 16 Feb 2021 01:49:11 +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 ABBB3120A42 for ; Tue, 16 Feb 2021 01:49:08 +0900 (JST) Received: by filterdrecv-p3mdw1-7c96677bb8-nd5lc with SMTP id filterdrecv-p3mdw1-7c96677bb8-nd5lc-18-602AA633-2D 2021-02-15 16:49:55.462067779 +0000 UTC m=+496875.791309901 Received: from herokuapp.com (unknown) by ismtpd0125p1mdw1.sendgrid.net (SG) with ESMTP id ExvpeUWVQuG609-POULGZA for ; Mon, 15 Feb 2021 16:49:55.391 +0000 (UTC) Date: Mon, 15 Feb 2021 16:49:55 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 78435 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?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr1RQQt=2F40AjwLp2mN7YXN?= =?us-ascii?Q?wq7DxgE9LEOpnL2+ZkVAr=2FYalFzvt14iA3LtXQz?= =?us-ascii?Q?OUYsj=2FGPXLWdbHB6j98jZOUZCYnGEVP9GsGUWk8?= =?us-ascii?Q?exuhkCcuPaG1PI0toQ+voZzAl7XgxhKkj7lTzRf?= =?us-ascii?Q?EMlSMMKQbbgdLdx6BBIt7qAl5T9zuLpO6HtGS0l?= =?us-ascii?Q?VUVMeZ+f90=2F7Z+PwM=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102507 Subject: [ruby-core:102507] [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). ko1 (Koichi Sasada) wrote in #note-14: > Sorry, I couldn't understand this point. > There is no special for class/module as a receiver objects (implementation is special, but no Ruby-level difference). > Do I miss something? There is a behavior difference, before Ractor `@foo` would always work and never raise. And `@foo =` would only raise if the receiver is frozen. Inside a Ractor, currently `@foo` works unless `self.is_a?(Module)`, same for `@foo =` (the inconsistency I mention: the same syntax has widely different semantics based on the receiver). If we accept this proposal, then at least `@foo` on a Module works if the value can be safely read (= the value is shareable). ---------------------------------------- Feature #17592: Ractor should allowing reading shareable class instance variables https://bugs.ruby-lang.org/issues/17592#change-90401 * 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/