Repository navigation
tape: index the carry-forward search, so a quiet node stops costing the whole tape - #7
Conversation
A frame carries every node's standing value, and `held` searched back from the cursor for the last fire of each node that was quiet. A node that fires twice a day — spl's market cap — or not at all that day — its classification — made that a walk over the entire retained tape, once per frame. Measured on spl's 42-node graph holding a day: 139ms to land a cursor at tick 159 000, 185ms for `n`, and linear in wherever the cursor sat. `fired` indexes it: per node, ascending, the positions it fired on. Positions and not `abs` ids because between thinning passes `ticks` only grows at the back, so a recorded position cannot move — and `thin`, the one thing that does move them, rebuilds the index in the walk it was already making. Derived, so it stays out of `TapeFile` and `load` rebuilds it. Measured, same machine, same day, spl at capacity 250 000: seek/step_until/step_until_change 0.8-139ms -> flat 0.9ms tape thread (viz_cost tape_s) 1.107s -> 1.109s, medians of 3 RSS 391MB -> 398MB graph thread untouched The sweep's synthetic mix gains a twice-a-day node, without which none of this was visible: its rarest node fired hourly, so the published latency was one nobody waits for. The reactivity chart now shows the raw round trip rather than the round trip minus the loopback hop, for the same reason. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts: # docs/.readme_assets/other.md # docs/capacity.txt
Code reviewReviewed the core change in exec_viz/src/tape.rs: the new Inner::fired per-node fire-position index, held's binary search via partition_point, and how the index is kept consistent across absorb (tick-append), thin (retention/compaction), and load (deserialize). Also checked the capacity.rs benchmark harness changes (new twice-daily Cap node, reactivity metric change) and the regenerated docs/benchmark numbers. What was checked:
Nothing rose to a high-confidence bug: the new index is built and consumed consistently everywhere it's touched, and the fix's own stated invariant (strictly better cursor latency, no added cost on the record path) holds up against the diff. One minor, low-severity observation (the pre-existing Viz::bytes() accounting doesn't include the new index's ~8 B/retained-fire) is out of scope for this diff since that function isn't touched by it. |
The bug
A frame carries every node's standing value, and
Inner::heldsearched backwards from the cursor for the last fire of each node that was quiet. A node that fires twice a day — spl's market cap — or not at all that day — its classification — turned that into a walk over the entire retained tape, once per frame.Measured on spl's 42-node graph at
capacity250 000, one day held whole:␣→/api/stepb→/api/step_until/api/seekn→/api/step_until_changeAnd it scaled with where the cursor sat — 0.8 ms at tick 100, 139 ms at tick 159 000. Now flat: 0.90 / 0.83 / 0.89 / 0.85 / 0.79 / 0.80 ms across the same six positions.
The fix
Inner::fired: per node, ascending, thetickspositions it fired on.heldbinary-searches it.Positions and not
absids because between thinning passesticksonly ever grows at the back, so a position already recorded cannot move — andthin, the one thing that does move them, rebuilds the index in the walk it was already making. Derived, so it stays out ofTapeFile;loadrebuilds it rather than trusting a file to agree with the ticks beside it, andTAPE_SCHEMAstays at 2.What it cost
The point of the exercise was that this had to be strictly better — no cost pushed onto the record path.
Rec::on/drop,Recorder::at)viz_costtape_stape_smedians are 1.107 vs 1.109 s across three runs each, inside the ±3% run-to-run spread — ~16 ns/tick, which is the ~7Vecpushes per tick it adds. Memory is oneusizeper retained fire.Why nobody saw it
The
capacitysweep's synthetic mix had five nodes whose rarest fired hourly, soheldalways terminated quickly and the published latency was one nobody waits for. The mix gains a twice-a-day node, which is what makes this measurable at all — and the reactivity chart now shows the raw round trip instead of the round trip minus the loopback hop, which was flattering it for the same reason.Re-swept block is in
docs/.readme_assets/other.md: latency is now flat across the wholecapacityrange and is entirely the socket, so the prose says plainly that the price ofcapacityis memory and only memory.Based on
db45f52, so it sits on top of theTape/Vizsplit.🤖 Generated with Claude Code