Open and answer this issue on GitHub.
async, decision · opened 2026-12-01 · updated 2026-12-01 · 0 comments
user-parallelism goes. The default and only build is multi-threaded. Each value gets its representation from the crossing analysis:
RefCell and no lock (today’s no code);yes code).user-pool in nikaia-runtime.toml sets the thread count, 1 included, with the ordinary code.Should the switch user-parallelism be removed, with each value’s representation chosen by the crossing analysis, and with a program run at user-pool = 1 running exactly the code no emits today?
The goal is the owner’s (2026-12-01): no switch, and no loss at one thread. The other aim is to carry no’s advantages over to the parallel build wherever the analysis proves that nothing crosses a thread. Neither a small measured loss nor a “close enough” loss justifies the change. This paper asks only whether this design is the direction to build in.
no and yes. They then set the goal above.no) is deferred until this question is decided.[build] user-parallelism in nikaia.toml (ADR-037 D5). It is read per manifest in project_settings.nika:363, with no as the default. --user-parallelism and NIKAIA_USER_PARALLELISM override it, and it is one dimension of the cache key.nikaia.contracts are the same at both settings (ADR-037 D4/D6), and one std serves both.no, every count is plain (ADR-312 D10), so SharedMut is Rc + RefCell;Locked has no lock at no (lock.rs Local, D2);no has no pool and a deterministic order.emit_core_calls.nika (4 places), sharing.nika, emit_program, emit_host, emit_kinds, threads, project_*, manifest and cli_commands;rt/*, lock.rs, task/*, par.rs, fs.rs, process.rs, net.rs, tls.rs, supervision.rs, cleanup.rs and grammar.rs.std to the switch: “Nothing in std’s Nikaia half may lower differently per build option” (30-nikaia-tooling.md:61).0. Do nothing. The switch stays a project key.
no stays as fast as it is.no cannot use a second core without a rebuild.A. A key for the root project only. Libraries are always built open, and the root decides.
B. One parallel build with cheaper primitives. Biased reference counting and biased locks: a non-atomic fast path for the owning thread, an atomic path otherwise.
Rc, and a biased lock about +6 Ir over RefCell. That misses the owner’s goal.C. Representation per value, plus a single-thread variant chosen at start (recommended).
a_crossing_reaches, NK2501, and the sharing analysis’s union-find) already decides for each allocation class whether it can cross a thread. A class that cannot cross gets today’s no representation (plain count, RefCell, Local lock). A class that can cross keeps the atomic floor. This is ADR-037 D6’s rule (“it may only take an atomic away”) made per value instead of per build.std specialised like user code. Today the switch reaches std only as a value its runtime is started with, and one compiled std serves both (30-nikaia-tooling.md). Under C, std’s types become generic over the mode marker. rustc then instantiates them in the program’s crate, so the compiled std in the cache is still one per machine. The rule “Nothing in std’s Nikaia half may lower differently per build option” becomes “differs only by the mode marker the analysis picks per value”. Shared and Locked can then be used in std’s Nikaia half.user-pool = 1 at start (nikaia-runtime.toml), it runs that variant, which is exactly the code no emits today, with the same order. This is what makes a run at one thread lossless by construction rather than by measurement.
SharedMut<T, M: Mode>, so that rustc’s monomorphisation does the duplication.no;yes.docs/measuring.md):| kind | Ir per op | vs. plain |
|---|---|---|
Rc clone+drop |
~8 | — |
Arc clone+drop |
~8 | (see caveat) |
| biased RC | ~16 | +8 |
RefCell borrow |
~7 | — |
| biased lock | ~13 | +6 |
Mutex lock+unlock |
~25 | +18 |
Arc looks as cheap as Rc. It is not: ADR-037 records +9 ns per pair, a timed figure. docs/measuring.md says nothing about atomics. For that reason the criterion here is identical code to no (identical code, identical cost), not an Ir comparison. Option C meets it by construction at one thread. B cannot meet it.Rc or Arc explicitly, per type, by hand.crossing = false variant at one thread must give today’s order of no. The probe is the current no tests run through the variant.dyn holding both kinds must be unified to the crossing kind. One probe per shape.--user-parallelism, [build] user-parallelism and NIKAIA_USER_PARALLELISM are removed, along with the cache dimension.30-nikaia-tooling.md:61 is reworded.user-pool in nikaia-runtime.toml also selects the variant (1 = the single-thread variant).SharedMut/Shared/Locked in the lowered Rust, chosen per allocation class from the sharing analysis.std instantiated per mode, and the reworded rule.C. It is the only alternative that removes the switch with no loss at one thread. It also carries no’s advantages into parallel runs for every value that does not cross.
Generated by Claude Code