Skip to content

perf(lynx): specialize compact run teardown - #706

Merged
trueadm merged 1 commit into
octanejs:mainfrom
Huxpro:huxcx/perf-lynx-compact-teardown
Aug 11, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
Huxpro:huxcx/perf-lynx-compact-teardown

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Specialize the Lynx host's complete teardown of a certified compact mount-template-run.

The current dense create path keeps first-mount host records lazy, but a 10k-row clear still validates and applies 100,000 teardown commands through the generic per-record path. On the attribution workload that meant 70,000 host records/event maps and put most of clear latency in host preparation/application.

This change retains a teardown-only dense certificate after an otherwise ordinary pure template run. A full clear may use it only after validating the complete event/remove/destroy stream, topology, generations, ownership, and absence of complex state. Mixed mutations, refs, lists, portals, main-thread props, native-list topology, or any mismatch remain on the existing generic path.

The fast path preserves synchronous PAPI removal/flush, native-event cleanup, destroy handle deltas and generations, terminal fault ownership, and the surrounding shell. It does not change the wire protocol or move cleanup past the measured boundary.

Tracks Huxpro#43.

Exact provenance

  • base: octanejs/octane@9b147781c9b4ec4df053a059633978ddc0ed922a
  • candidate: 8d8883c8ba01fd6061afbf3fec43df11ebd8d465
  • host: 32-core Intel Xeon Platinum 8336C, Node 22.22.2, Chromium 149.0.7827.55
  • neutral benchmark: Huxpro/lynx-js-framework-benchmark, byte-identical runner and production bundles for both entries

Performance

Primary command (then repeated with entries reversed):

pnpm bench -- run \
  --entry octane-main,octane-issue43 \
  --case create,update10th,select,clear,updateStorm,selectStorm \
  --scale 0,1000,10000,30000 \
  --suite table,startup \
  --reps 7 --storm-reps 3 --startup-reps 5
order base clear@10k candidate clear@10k delta
forward 974.2 ±20.1 ms 762.6 ±24.3 ms -21.7%
reverse 1050.7 ±55.2 ms 720.0 ±30.1 ms -31.5%

No accepted adverse decision cell remained:

  • create@1k/10k/30k order-balanced deltas: +2.7% / +0.8% / +1.0%
  • storms: update improved in both orders at 10k and 30k; worst order-balanced select-storm cell was +3.6% at 30k
  • the noisy n=7 update/select@10k cells were repeated at n=20 in both orders: update was -14.9% forward and -2.7% reverse; select was -5.1% forward and +2.1% reverse
  • startup@0 was repeated at n=20 after the n=5 forward sample moved by about 4 ms: 50.0 → 50.5 ms (+1.2%); startup@30k was 5508.1 → 5527.1 ms (+0.3%)
  • startup@1k/10k/30k in the original forward/reverse matrix stayed within +3.0%; candidate improved startup@10k in both orders

Raw result SHA-256:

  • forward matrix: 90d4449a5a5274c2a21a825930a185c28da73d6ff5ddd06a04743ef0580d0789
  • reverse matrix: 97ac1b4aa346dfa39c95a9bbbc6b394ec8776159db6706caf96a782c5bd2e278
  • n=20 update/select forward: 6be4565a103f8fe6da38a7f2b6ac0d68b7b1b60e64b13981b827a7a87743aff7
  • n=20 update/select reverse: d2eae84a155a0e935ac680bd6317ef91b7a5e64972970f72f6c643f868ea44ce

Attribution and cleanup gates

The final instrumented lifecycle used two create/clear warmups, explicit CDP GC, then measured create/clear/page close on fresh pages. Every candidate repetition recorded exactly:

  • denseFastTeardowns = 1
  • denseFastTeardownHosts = 70,000
  • unchanged teardown wire work: 100,000 commands (20k event removals, 10k root removals, 70k destroys)

With the identical lifecycle:

metric base median candidate median
clear@10k 894.2 ms 585.3 ms
held heap 42,220,672 B 42,218,772 B
post-clear residual 25,595,760 B 25,594,348 B
page-close → worker release 7.5 ms 6.5 ms

All five baseline and candidate workers released. The final counter capture repeated the candidate three more times; every sample hit one 70,000-host teardown certificate, synchronously cleared, and released its worker.

Bundle impact

Production bundle gzip at the benchmark's 10k build:

bundle base candidate delta
Web gzip 131,677 B 133,489 B +1.38%
Lynx gzip 158,662 B 160,965 B +1.45%

Both are below the 5% gate. @octanejs/lynx is private at 0.0.0, so no changeset is applicable.

Correctness and validation

Tests cover aborted preparation, exact shell/survivor identity, event removal, destroy-delta order, generation-2 repeated teardown and generation-3 ID reuse, empty-batch certificate preservation, and terminal cleanup after a fast-path PAPI fault. Removing the event cleanup assertion path made the new regression fail before it was restored.

Commands run:

pnpm --filter @octanejs/lynx test -- --silent=passed-only
# 24 files, 338 tests passed

pnpm typecheck:files packages/lynx/src/core/host-driver.ts
pnpm format:files:check packages/lynx/src/core/host-driver.ts packages/lynx/tests/host-driver.test.ts
node benchmarks/bench.mjs --only lynx-table --ratios
# 18 applicable guards passed
pnpm sync

The package-wide Lynx typecheck also reproduces the same existing main-thread.ts:2197 acknowledgement-narrowing error on the exact clean base; the changed host-driver.ts scoped typecheck passes.

Risk

The optimization is deliberately fail-closed. Certification walks and compares the exact accepted topology and teardown stream before mutation; any unsupported ownership or lifetime state falls back to the generic implementation. Once application begins, failures retain terminal cleanup ownership and still attempt the required flush, matching the existing accepted-fault contract.


Note

Cursor Bugbot is generating a summary for commit 8d8883c. Configure here.

@vercel

vercel Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
octane-website Skipped Skipped Aug 11, 2026 5:17pm
octane-website-mcp Skipped Skipped Aug 11, 2026 5:17pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp August 11, 2026 17:17 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website August 11, 2026 17:17 Inactive
@github-actions github-actions Bot added the perf PR: performance work label Aug 11, 2026
@trueadm
trueadm merged commit 47ff0a3 into octanejs:main Aug 11, 2026
37 checks passed

This branch was previously deployed

2 inactive deployments
Preview – octane-website-mcp — 8d8883c8 Deployed Aug 11, 2026 by vercel[bot]
Preview – octane-website — 8d8883c8 Deployed Aug 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants