Repository navigation
perf: tear down removed collapsed runs with one destroy-run command - #750
Merged
Merged
Conversation
…ation Add a speed-of-light probe that materializes the exact 10,000-row table shape with a bare public Element PAPI loop in the same main-thread realm as the Lynx receiver, interleaved AB/BA with octane control/profile create cells, and record the measured floor: - papi_element_creation is 99.0% platform floor (collapsible 0.5% of the create wall) - mt_apply_other is 84.7% floor-equivalent (collapsible 4.6%) - chunked vs single flush makes no difference All three sub-owner candidates from the roadmap fail the >=10% owner gate for per-element MTS machinery on the web harness.
A compact first mount could only engage once per root: the main thread kept implicitInitialGenerations set forever and the background client refused further compact acknowledgements while retired segment metadata existed, so every create after a clear republished a full per-host handle delta - 17.4 MB of reverse traffic, ~600 ms of main-thread wall, and eager background materialization of all 70k handle entries on the shared 10k-row table. The public benchmark's warmed-page protocol measures exactly this path. - reset implicit generation bookkeeping when a certified dense teardown leaves every surviving record's generation stored - gate compact eligibility on a fresh-id ratchet (maxExplicitId) so implicit generation-one segments can never cover a reused id and remounts keep bumping generations on the explicit path - retire background compact metadata when its last live host code is removed, restoring it on rollback Create-after-clear acknowledgement: 17,330,831 B -> 719 B; warmed-page create@10k wall median 2,028 -> 1,511 ms on the same host with fresh cells unchanged. Adds bts-profile.mjs (background/page attribution with wire deltas, fresh vs warmed-protocol cells) and its measured results.
Clearing a 10k-row keyed table shipped a 100,000-command teardown stream (3.5 MB), acknowledged it with 70,000 tombstone deltas (2.9 MB), expanded every removed collapsed row into seven logical records just to enumerate those commands, and grew both threads' generation tables by 70,000 entries per cycle. The universal renderer now advertises a teardownRuns driver capability: a removed subtree that is still a collapsed program-run instance with implicit contiguous ids skips expansion and contributes to one destroy-run command per contiguous range. The Lynx binding negotiates the capability, re-enters the certified teardown fast path by expanding the command against its dense record store (with an accepted-records fallback and a general-loop path for partial ranges), acknowledges a full-run teardown with a single remove-run delta, and records one sorted retired-range tombstone per side instead of 70,000 map entries. Clear command stream 3,514,556 B -> ~370 B; clear acknowledgement 2,929,786 B -> ~813 B; compact create acknowledgements survive the cycle. Reused ranges keep bumping generations; emitter-, host-, and client-side regression tests were observed red before the change.
1 task done
11 tasks done
# Conflicts: # benchmarks/lynx-table/stages/papi-floor.mjs # benchmarks/lynx-table/stages/results/bts-profile-10000.json # benchmarks/lynx-table/stages/results/papi-floor-10000.json # benchmarks/lynx-table/stages/results/papi-floor-10000.md # packages/lynx/src/core/client-driver.ts # packages/lynx/src/core/host-driver.ts # packages/lynx/tests/host-driver.test.ts # packages/lynx/tests/protocol.test.ts
…rdown-runs # Conflicts: # packages/lynx/tests/host-driver.test.ts # packages/lynx/tests/protocol.test.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit e611944. Configure here.
trueadm
marked this pull request as ready for review
August 13, 2026 19:42
1 task done
4 of 5 tasks
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
… to renderers that use them (#1652) * perf(octane): ship universal host bindings and template programs only to renderers that use them Weekly Bench's three-bundle-size guards breached at 1.059x (minimal) and 1.042x (full catalogue) of React Three Fiber. Since #677, octane-min grew 15.6 KB gzip, almost all of it in universal-core.ts (131 KB -> 178 KB minified). The largest additions were Lynx-only template paths (#693, #700, #716, #750) and opt-in host bindings (#1044). @octanejs/three itself was flat. - universalHostBinding() now installs the subscription, flush, and binding-only transaction code on its first call. The root keeps one lazy binding state instead of seven eager fields, and commits skip the per-host binding loops when no binding can exist. - Template programs are a driver opt-in: templateProgramMount, templateProgramRuns, and collapsedTemplateMount take effect only with `templates: universalHostTemplates`. The Lynx background driver passes it. Program preparation, collapsed-template materialization and expansion, and the compact template update now sit behind that object. octane-min 199019 -> 193811 gzip (1.031x), octane-full 260746 -> 255569 (1.021x). The guards ratchet to 1.034 and 1.024; reaching 1.0 needs a broader universal-core diet. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore: split the Lynx changeset from the octane changeset The changeset check rejects a changeset that mixes the ignored private @octanejs/lynx package with octane. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
teardownRunsuniversal driver capability: a removed subtree that isstill a collapsed program-run instance with implicit contiguous ids skips
expansion and contributes to one
destroy-runcommand per contiguous range,instead of one event/remove/destroy command per host
readiness request base), expand the command against the dense record store to
re-enter the certified teardown fast path (accepted-records fallback for
reordered/explicit-path rows; general command loop for partial ranges), and
acknowledge a full-run teardown with a single
remove-rundeltageneration-map entries per clear cycle; the background client retires compact
metadata without materializing handles it never observed
Why
Roadmap item 3 of Huxpro#51. Clearing the shared 10k-row table paid four
O(hosts) costs for an O(runs) operation, measured in the item-2 evidence:
3.5 MB / 100k-command teardown stream, 2.9 MB acknowledgement of 70k tombstone
deltas, background expansion of every removed collapsed row (70k logical
records per clear), and 70k generation tombstones per cycle on both threads
(unbounded growth across cycles). #706 kept the command stream as the teardown
certificate; the run command keeps the certificate by construction — the
receiver re-derives the certified sequence from the program it already holds.
Measured effect (shared table app, same host)
predecessor (~730 B), including across repeated cycles
both entry orders): clear@10k latency 0.74×/0.81×, btsCpu 0.30×/0.30×,
mtsCpu 0.82×/0.83×; create@10k latency 0.83×/0.82×, btsCpu 0.21×/0.21×
(the clear-ACK materialization no longer poisons later creates); select@10k
0.74×/0.84×; replace@1k 0.91×/0.90×; heap cells 1.00; startup fcp ≤1.0×
forward and ≈1.0 reverse at every scale. Adverse audit: two sub-frame cells
read >1.05 in both orders — selectStorm@1k (+3.5 ms on ~33 ms) and
update10th@1k latency (+1.7/+3.4 ms on ~22 ms) — while their @10k
counterparts win both orders; same boundary-noise signature as the
predecessor's settle finding, flagged for the reference-machine rerun.
create@10k 1906 → 1148 ms (0.60×) = 0.99× same-container React; clear@10k
692 → 676 ms while absorbing the predecessor's measurement-boundary debt.
Fallback semantics preserved
visibility keep the per-host path; drivers that do not advertise the
capability (the DOM boundary) are byte-for-byte unchanged.
destroy-runexpands into the general command loop; unknownranges are rejected before any mutation; reused id ranges keep bumping
generations (retired ranges act as generation-one tombstones).
metadata, and retired ranges.
Validation
change (5 tests across three suites)
packages/lynxsuite: 345 passed; universal suites: 344 passedtsc --noEmitclean onoctaneand clean relative tobase on
@octanejs/lynx(one pre-existing unrelated error)pnpm format:files:checkon changed files;pnpm synccleancreate/clear cycles
repo with vendored Lab entries at this commit)
Risk / follow-ups
thread (O(hosts) object churn without wire/parse costs); moving the certified
validation to consume the run directly is a follow-up if MTS profiles show it.
Provenance
agent-authored)🤖 Generated with Claude Code
Generated by Claude Code
Note
Medium Risk
Touches cross-thread commit/ack bookkeeping and host id lifecycle (retired ranges, generation checks); fallbacks preserve prior behavior but Lynx teardown correctness is security- and stability-sensitive at scale.
Overview
Clears of large keyed tables no longer expand every removed collapsed row into per-host remove/destroy/event commands. The universal renderer gains a
teardownRunscapability and adestroy-runhost command; eligible removed program-run subtrees (implicit contiguous ids, no refs/portals/callbacks) are coalesced into one command per contiguous range instead of expanding to per-host teardown.The Lynx stack negotiates
teardownRuns(new readiness request base), expandsdestroy-runon the main thread against the dense record store (certified fast path for full runs; records fallback for reordered/explicit rows; general loop for partial ranges), and answers full-run teardown with a singleremove-runacknowledgement delta. Both threads replace per-host generation tombstones with sorted retired[first, last]ranges; the background client retires compact metadata without materializing handles it never saw.Drivers without the capability (e.g. DOM) and rows that need per-host observability keep the previous explicit path. Regression tests cover partial teardown, post-fault clears, rollback, and id reuse/generation bumps.
Reviewed by Cursor Bugbot for commit d00a52c. Bugbot is set up for automated code reviews on this repo. Configure here.