Issue #3018: A stream’s lines handed to a task run 42 % more instructions than a Rust control

Open and answer this issue on GitHub.

ready · opened 2026-12-01 · updated 2026-12-01 · 0 comments

Finding

The program of “A stream’s views handed to a task over a bounded channel, counted with the cheapest of four steps” (#2854) item 1 runs about 42 % more instructions than a Rust control that does the same work with an Arc per buffer. The program reads io::lines(), sends each line on channel::bounded(8) to a detached task, and the task writes it.

Measured in #2854 run 3: callgrind with branch simulation, 46,549 lines / 2 MB, blocking I/O, release builds, identical output.

Version Ir Mispredicts
Nikaia, one cursor (D5 step 2) 106,967,290 943,577
Nikaia, atomic count per buffer (D5 step 4) 106,020,196 961,339
Rust control, Arc per buffer 75,066,242 736,461

The way views are counted is not the cause: the two counting steps differ by 0.9 %. The 32 M Ir come from elsewhere, for example the line split, the channel, the task’s write, or the pool’s open. docs/measuring.md measures against tuned Rust.

To build

  1. Count per function with callgrind (--dump-instr=no, callgrind_annotate) for the Nikaia program and the control, and name where the difference lies.
  2. Fix each part in the compiler, std or crates/unsafe/tether, as its own commit, measured.
  3. If a part can only close by a language or ADR decision, stop and file it as decision.

Done when

The program is within the control’s Ir, or every remaining difference is named, with its issue or ADR.


Generated by Claude Code

Back to Open Issues