Commit 6904042d

6904042dcd2cMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 21 files · ~13 modified · -8 deleted

Description

Revert "Merge pull request #1448 from OriPekelman/rfc-minimal-ractor"

This reverts commit 1d7ade7b635763eca21e74498863ec87038a5e05, reversing changes made to 789790697cbe1a529a06a36779b53b69bea7a92b.

Details

Commit
6904042dcd2c
Parent
4a7e0e39dcf2

docs/RACTOR-RFC.mdmodifiedView file

@@ -1,9 +1,7 @@
11 # RFC: A Minimal Ractor for Spinel
22
3-Status: **experimental / Milestone 6** (working; ported to the C compiler in
4-`src/`). Deep-copy message codec spans immediates / Symbol / String / Array /
5-Hash / user-objects; `Ractor.new` spawn arguments; compile-time `@@cvar`/`$gvar`
6-isolation; and a shared `Ractor::Port` channel. This document is both the design
3+Status: **experimental / Milestone 2** (working; ported to the C compiler in
4+`src/`). This document is both the design
75 rationale and the record of what currently ships. It proposes whether to
86 graduate to a full implementation (see *Path forward*).
97
@@ -121,23 +119,20 @@
121119
122120 ## Deliberate divergences (where "minimal" buys simplicity)
123121
124-1. **Value codec covers immediates, Symbol, String, Arrays, and Hashes** (poly
125- + typed variants), deep-copied recursively through a heap-neutral malloc'd
126- blob (`sp_ractor_serialize`/`_deserialize`, installed via a hook because the
127- rebuild allocators are static to the generated TU). Plain objects, Procs,
128- Fibers, and IO raise `Ractor::Error` at the boundary — extending the codec to
129- user objects is the main follow-up. Symbols travel by name and are
130- re-interned in the receiver's per-Ractor table; hashes are normalised to a
131- poly hash on rebuild. The same codec seeds `Ractor.new(args) { |params| }`
132- spawn arguments.
122+1. **Value codec covers immediates, Symbol, String, and Arrays** (poly + typed
123+ int/float/string), deep-copied through a heap-neutral malloc'd blob
124+ (`sp_ractor_serialize`/`_deserialize`, installed via a hook because the
125+ rebuild allocators are static to the generated TU). Hashes, plain objects,
126+ Procs, Fibers, and IO raise `Ractor::Error` at the boundary — extending the
127+ codec to those (and to nested objects) is the main follow-up. Symbols travel
128+ by name and are re-interned in the receiver's per-Ractor table.
133129 2. **FIFO mailbox / outgoing queue** (mutex + condvar, grows on demand), so a
134130 Ractor may `receive` several messages and a sender need not block per slot.
135-3. **`@@cvars` / `$globals` accessed inside a Ractor are rejected at compile
136- time** with `Ractor::IsolationError`, mirroring CRuby (which raises on
137- cross-Ractor class-variable / global access). Special, thread-local or
138- read-only globals (`$~`, `$stdout`, regex/status specials — not user-declared)
139- are allowed. The globals themselves remain `__thread` in the runtime; the
140- compile-time check just prevents the silent-empty-value footgun.
131+3. **`@@cvars` / `$globals` are `__thread`** → isolated per Ractor, rather than
132+ CRuby's "shared, raise on cross-Ractor mutation". Simpler and safe, but a
133+ real semantic difference: a class-body cvar initializer has not run in a
134+ child Ractor unless re-executed there. Programs that rely on cross-Ractor
135+ cvar/gvar sharing are out of scope for this milestone.
141136 4. **`Ractor#send` with a bare String/Symbol *literal*** is parsed as a
142137 reflective send (`recv.send("m")` → `recv.m`, a whole-program parser
143138 behaviour), so send messages via `r << v` or a local (`r.send(v)`); literals
@@ -167,21 +162,9 @@
167162
168163 ## Path forward (if this graduates)
169164
170-Done since the original RFC: the deep-copy codec now spans strings → symbols →
171-arrays → hashes → **user objects/structs** (M2/M3b/M4, recursively); the mailbox
172-is an unbounded FIFO; `Ractor.new(args){|p|}` spawn arguments are deep-copied in
173-(M3a); `@@cvar`/`$gvar` access inside a Ractor is rejected at compile time (M5);
174-and **`Ractor::Port`** provides a process-shared channel (`new`/`send`/`receive`/
175-`close`), passed across the boundary *by reference* so producers and consumers
176-on different Ractors rendezvous through it (M6). Remaining: shareable-by-value
177-frozen captures, object-graph cycles in the codec (acyclic assumed today), and
178-the Ruby-3.5 Ractor-as-Port API reshaping. None change the core partition.
179-
180-### API sharp edges (operator/method overload collisions)
181-
182-- **`Ractor#send` / `Ractor::Port#send` with a bare String/Symbol *literal*** is
183- parsed as a reflective send (`x.send("m")` → `x.m`, a whole-program parser
184- behaviour). Send via `x.send(var)` or an Integer literal; `x.send("lit")` is
185- reflective.
186-- **`port << v`** can be mis-inferred as an Array push (the `<<` push-promotion
187- heuristic types the receiver as an array). Use `port.send(v)` for ports.
165+In rough dependency order: extend `sp_deep_copy` to strings → arrays → hashes →
166+objects (symbols travel by name, re-interned on receive); make the mailbox
167+unbounded; thread-local-ize `@@cvars`/`$globals` with a class-body initializer
168+replay on the child; add spawn args and shareable-by-value capture; and a
169+`Ractor::Port`-style multi-consumer surface. None of these change the core
170+partition above — they extend it.