Skip to content

perf(lynx): streamline dense clear teardown - #762

Merged
trueadm merged 2 commits into
octanejs:mainfrom
Huxpro:fix/lynx-clear-direct-teardown
Aug 16, 2026
Merged

trueadm merged 2 commits into
octanejs:mainfrom
Huxpro:fix/lynx-clear-direct-teardown

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • certify and consume an exact sole pristine dense destroy-run without materializing per-host teardown commands
  • release native-event journal entries structurally only after every root removal succeeds, while preserving the expanded path for all non-eligible and faulted states
  • expose the receiver-bound raw Element PAPI remove function and add compile-time-gated attribution counters plus reproducible benchmark evidence

Refs Huxpro#57.

Why

The 10,000-row Lynx clear path synthesized 100,000 commands, explicitly detached 20,000 events, and revalidated the full dense store before performing the unavoidable 10,000 native root removals. This kept Octane materially behind the React/Vue tier even though the accepted dense state already proved the exact teardown shape.

Changes

  • Direct certification is limited to an untouched, sole, full, uniform dense run with matching parent/order/generation and no portal, list, ref, main-thread-prop, reuse, or fault state.
  • Direct apply removes the certified roots without command expansion. Event journal release happens only after all removals succeed, so before/after PAPI faults retain complete terminal-cleanup authority.
  • Partial, reordered, mutated, non-uniform, reused, stale, aborted, and faulted cases continue through the existing expanded validation path.
  • The benchmark harness now records expansion, validation, event teardown, PAPI removal, dense release, and operation counts. The supported Rspeedy/Rspack production bundles were verified to eliminate the profile global and fields; this does not claim byte-identical dead-code elimination for arbitrary bundlers.
  • Adds an @octanejs/lynx patch changeset, structured evidence with all bundle SHA-256 values, and nine deterministic raw-run archives under benchmarks/lynx-table/stages/results/issue57-clear-teardown*.

Performance

Same machine, pinned Chromium, production bundles, seven repetitions, zero DNF:

Order Candidate React Fastest comparable Vue Candidate / React Candidate / Vue
forward 259.880 ±17.478 ms 325.015 ms 223.270 ms 0.800× 1.164×
reverse repeat 267.950 ±23.304 ms 327.885 ms 247.585 ms 0.817× 1.082×

Adjacent AB/BA comparison against upstream improved clear by 23.8% and 19.3%. The 38-cell challenge matrix had zero DNF and no latency/FCP cell regressed by more than 5% in both orders. Production bundle deltas were +463 B gzip web and +688 B gzip Lynx; measured 10k heap decreased on both threads.

Full raw samples, attribution counters, rejected candidates, secondary costs, and the disclosed earlier noisy reverse cohort are in the committed evidence report. The original featured, profile, performance AB/BA, and challenge AB/BA runner files are committed as .json.gz archives with verified hashes.

Validation

  • pnpm format:check — not run repo-wide; all changed text files passed targeted Prettier checks
  • pnpm typecheck — not run repo-wide; changed Lynx production files passed scoped typecheck and packages/lynx/tsconfig.testing.json passed
  • pnpm test — 2,190/2,193 files and 21,588/21,603 tests passed in the full concurrent run; the 15 failures were fixed timeouts/one Vite 504 Outdated Optimize Dep
  • targeted tests: Lynx 25/25 files, 350/350 tests; benchmark instrumentation Node test; isolated reruns of all full-suite failures passed (CLI 8/8, website MCP 9/9, browser native-change 12/12); 9 raw-run archives and 16 bundle hashes verified against source artifacts
  • pnpm sync
  • git diff --check

Risk / follow-ups

  • Eligibility is intentionally narrow; every state that cannot be certified retains the existing teardown semantics and tests.
  • The remaining dominant owner is the 10,000 native PAPI/DOM removals. Bulk replacement, reverse removal, packed/unrolled loops, and text fusion were measured or audited and rejected rather than added as benchmark-specific shortcuts.

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Changes certified teardown and native-event lifetime in core host-driver paths; eligibility is narrow and heavily tested, but incorrect certification could leak events or skip cleanup on edge states.

Overview
Adds a fast path for a sole, pristine dense destroy-run: the host certifies eligibility on an untouched dense store (tracked via a new mutated flag) and tears down without expanding into per-host commands or running thousands of explicit native event unbinds.

Direct apply removes certified run roots in stride, clears the native-event journal structurally only after all PAPI removals succeed (so partial faults still get full terminal cleanup), and keeps the existing expansion/validation path for partial, reordered, mutated, portal/list/ref, faulted, and reused states.

Profiling and benchmarks gain stage timers and counters (destroyRunExpandMs, denseValidateMs, eventDetachMs, papiRemoveMs, synthesizedCommands, etc.) wired through the Lynx table harness; committed issue-57 evidence documents large clear wins with no dual-order regressions above 5%.

Tests extend the fake PAPI and host-driver coverage for direct teardown, foreign siblings, mutation/reorder fallbacks, stale batches, and fault timing around event cleanup. papi.ts exposes the receiver-bound remove reference unchanged in behavior.

Reviewed by Cursor Bugbot for commit 5c4addb. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants