Skip to content

[lynx-perf-live 9] Loop: drive clear teardown toward the Vue/React tier #57

Open

Description

@Huxpro

Classification

Performance roadmap focused exclusively on the remaining Lynx table clear@10k
gap after upstream #748,
#749,
#750, and
#751. This is a teardown-specific
child of #51, not a replacement for its create/FCP, adoption, bundle, or native
tracks.

Problem statement

The original baseline of record (octanejs/octane@6079a680) measured
clear@10k at 706 ms versus React at 320 ms and the Vue cells at 229–295 ms.
The destroy-run work in upstream octanejs#750 removed the O(hosts) wire stream and
improved its AB/BA predecessor by roughly 19–26%, but the last measured
candidate still landed around 676–730 ms.

The improvement was real, but it did not close the cross-framework gap. The
remaining path is dominated by main-thread physical teardown rather than BTS
reconciliation:

  1. a compact destroy-run is expanded on MTS into the certified per-host
    event/remove/destroy sequence;
  2. the dense fast path still performs one PAPI remove per row root (10,000
    calls for the shared table) plus host-state cleanup for roughly 70,000
    hosts;
  3. warmed generations and retired ranges can force per-host handle or
    acknowledgement work unless the exact compact path remains engaged;
  4. DOM/custom-element removal, composed-tree predicate polling, and GC account
    for most of the residual wall time.

The public benchmark's featured octane entry is still vendored from
6079a680; upstream main is now past all four PRs. No new optimization claim
starts until current main has a same-run baseline.

Objective

Iterate owner-first on teardown until Octane is as close as its observable
semantics and the shared Lynx PAPI allow to the same-run Vue/React cells.

Staged targets for clear@10k on the unchanged shared Web harness:

These are goals, not permission to weaken teardown correctness, change the
benchmark workload/predicate, or introduce a Web-only shortcut that cannot be
explained against native semantics.

Loop protocol

Every iteration follows this loop and posts its complete ledger as an issue
comment:

  1. Measure one owner. Attribute BTS render, wire/clone, MTS
    validate/expand, PAPI removal, handle publication/ACK, driver predicate,
    and GC. A production experiment needs a directly measured owner >= 10% of
    the decision cell.
  2. State a falsifiable hypothesis. Include the expected counter/phase
    movement, the semantic control, and a negative-control workload where the
    win should disappear.
  3. Implement one rollback-sized change. Keep fallback behavior unchanged
    for explicit ids, refs, events, portals, partial/reordered runs, faults,
    rollback, and drivers without the new capability.
  4. Validate AB/BA. Same machine, lockfile, bundles, and harness; n>=7 in
    both entry orders, zero DNF. Report medians, raw samples, CI, bundle/heap,
    wire/message counts, and phase attribution.
  5. Challenge cost transfer. Check create-after-clear, remove, replace,
    startup/FCP, storms, MTS/BTS heap, GC, and subsequent generation reuse.
    No tracked large cell may regress >5% in both orders without an explicit
    accepted tradeoff.
  6. Keep or revert. Land upstream only if the owner moved as predicted and
    semantic controls stayed green. After merge, re-vendor upstream main and
    make that result the next iteration's baseline.

Stop an avenue after two well-powered NO-GO results or once its measured
collapsible share falls below 10%; move to the next owner instead of tuning
noise.

Work plan

0. Current-main baseline and honest boundary controls

  • Re-vendor the featured entry from current unpatched octanejs/octane/main
    and run the full featured cohort in one window.
  • Run an additional attribution-only control that settles setup create work
    before timed clear. Keep the published workload unchanged; use the control
    only to distinguish teardown cost from predecessor boundary debt.
  • Archive entry commit, bundle hashes, host fingerprint, raw samples, zero-DNF
    count, and same-run Vue/React ratios.

1. Phase ledger and deterministic counters

  • Add/extend profiling for destroy-run decode, certificate validation,
    synthetic-command construction, dense-store cleanup, PAPI calls,
    acknowledgement construction/acceptance, predicate polling, and GC.
  • Record deterministic counts per clear: received run commands, synthesized
    command objects, PAPI removes, materialized host records/deltas, generation
    entries/ranges, ACK bytes, and retained state after GC.
  • Confirm whether the final perf: tear down removed collapsed runs with one destroy-run command octanejs/octane#750 correctness commits changed the fast-path hit
    rate or only its validation.

2. Consume certified runs directly on MTS

  • Prototype a dense teardown plan that validates and executes destroy-run
    from the accepted program/store without allocating the per-host command
    array.
  • Preserve the explicit/partial/reordered fallback and exact rollback/error
    contract.
  • Success criterion: synthesized command objects become O(runs), the targeted
    MTS phase falls by >=50%, and clear wall improves outside variance.

3. Keep teardown ACK and generations O(runs) across warmed cycles

  • Verify three or more create/clear cycles, reused ids, mixed generations,
    partial removals, and rollback.
  • Remove any remaining path that materializes one handle delta or generation
    tombstone per retired host when a certified run/range is sufficient.
  • Success criterion: clear ACK, new generation state, and retired metadata stay
    O(runs) on every certified cycle, with no growth proportional to cleared
    hosts.

4. Reduce physical PAPI removal calls

  • Measure alternatives in isolation: current per-row root removal, scoped
    range/subtree removal, parent-owned child clear, detach-and-replace, or a
    negotiated bulk-remove capability.
  • Prefer an owning host abstraction over benchmark-app special cases. If the
    public Lynx PAPI has no semantic bulk primitive, document the floor and
    prototype the narrowest capability extension with a correct fallback.
  • Test native-facing ordering, event/ref cleanup, portals, lists, and foreign
    siblings before accepting a Web win.
  • Success criterion: physical removal calls become O(runs/subtrees), or a
    measured platform floor proves why they cannot.

5. Metadata, GC, and post-clear latency

  • Attribute allocations retained or collected during run expansion, record
    disposal, owned-node cleanup, handle publication, and retired-range
    maintenance.
  • Pool/reuse only after lifetime and rollback invalidation are proven.
  • Measure the whole create -> clear -> create cycle so work cannot be hidden
    after the row-count predicate or shifted into the next create.

6. Re-rank and repeat

  • After each accepted upstream PR, publish a new full featured-cohort run and
    update the owner ledger.
  • Open the next implementation issue/PR only for the largest remaining >=10%
    owner.
  • Continue until the Goal is met or every remaining gap is a measured shared
    PAPI/browser/harness floor; document any residual floor with a negative
    control rather than claiming parity.

Correctness matrix

  • complete and partial run clear; reordered and explicit-path rows
  • refs, main-thread props/events, portals, lists, foreign siblings
  • reused ids and non-uniform generations across repeated cycles
  • faulted roots, apply failure, rollback, stale/duplicate ACK
  • first-screen/adopted trees and root disposal
  • drivers with and without teardown/bulk-remove capabilities
  • Web and native semantics kept distinct; no native claim from Web-only data

Deliverables per iteration

  • baseline/candidate bundles with provenance and hashes
  • raw AB/BA result files and concise phase/counter report
  • regression tests that fail on the prior behavior
  • one upstream draft PR with explicit performance and risk ledger
  • post-merge featured benchmark refresh and issue comment

Non-goals

  • benchmark-specific DOM or predicate shortcuts
  • removing required user cleanups, ref/event detachment, generation checks, or
    rollback validation
  • more wire encoding work without a newly measured wire owner
  • exact percentage claims across different hosts or separate benchmark runs
  • declaring Vue/React parity from a stale featured entry

Provenance

  • An agent authored this issue (agent-authored).

Activity

  1. Huxpro commented on Aug 15, 2026

    @Huxpro
    OwnerAuthor

    Iteration ledger: direct pristine dense teardown

    Upstream draft PR: octanejs/octane#762
    Head: 5c4addb8bb3473f7487cdc9552ca2d1f531cef4a

    Baseline and hypothesis

    • Baseline is current unpatched octanejs/octane@63eb788817ff91b841b5f0fd24321ae16e7f4396, rebuilt on the same lockfile and machine as the candidate.
    • Profiled clear owner: 100,000 synthesized commands, 31.405 ms dense validation, 20,000 explicit native event detachments / 33.435 ms, and 10,000 Element PAPI removes / 175.960 ms.
    • Falsifiable hypothesis: consuming a sole/full/pristine/uniform accepted dense run directly would reduce synthesized commands to zero, make dense validation sub-millisecond, and remove explicit event detach work without changing the unavoidable 10,000 native root removals.
    • Negative control: non-pristine clear must stay on the expanded path and should not reproduce the direct-path win.

    Kept change

    • Direct certification checks exact store identity, parent, width/count/first id, root order, implicit generations, and absence of mutation, faults, portals, lists, refs, main-thread props, and reuse state.
    • Direct apply removes accepted roots in stride without expanding commands. Native event journal release happens only after every root removal succeeds, preserving terminal-disposal authority for before/after PAPI faults.
    • Partial, reordered, mutated, non-uniform, reused, stale, aborted, portal/list/ref, and faulted cases keep the existing expansion/validation path.
    • createLynxElementPAPI exposes the already receiver-bound raw remove function; profiling counters remain compile-time gated. Absence of the profile global/fields was verified in supported Rspeedy/Rspack production bundles (not claimed for arbitrary bundlers).

    Decision result

    Same machine (65160668d8d9, Xeon Platinum 8336C), pinned Playwright Chromium 1228, production bundles, n=7, zero DNF:

    Entry order Candidate clear@10k 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×

    The issue Goal (<=1.1× React, <=1.25× fastest comparable Vue) is met in both reportable orders. One earlier reverse cohort was 308.100 ±16.300 ms / 1.272× Vue; the identical-order repeat above passed, and the noisy cohort is disclosed rather than discarded.

    Adjacent baseline/candidate AB/BA:

    Order Upstream Candidate Change
    upstream → candidate 391.105 ms 297.995 ms -23.8%
    candidate → upstream 363.455 ms 293.345 ms -19.3%

    Attribution and cost transfer

    Owner Baseline Candidate Count movement
    destroy-run expansion 13.710 ms 0 ms 100,000 → 0 commands
    dense validation 31.405 ms 0.550 ms expanded validation → direct certification
    event teardown 33.435 ms 0.035 ms 20,000 explicit detachments → 0 + one journal clear
    Element PAPI removal 175.960 ms 175.520 ms 10,000 → 10,000 root removes
    dense release 0.035 ms 0.030 ms 70,000 → 70,000 hosts
    • Challenge matrix: create, replace, append, update10th, select, swap, remove, non-pristine fallback clear, update/select storms, and startup at 0/1k/10k/30k; 38 latency/FCP cells, zero DNF, no cell >5% worse in both orders.
    • Negative-control non-pristine clear: -1.0% AB / +1.2% BA.
    • Bundle delta: web +2,132 B raw / +463 B gzip; Lynx +1,572 B raw / +688 B gzip.
    • Heap @10k: MTS -757,748 B; BTS -260 B. Wire remained one MTS message and four BTS messages (+2 BTS bytes).

    Semantic controls and validation

    • Regression coverage includes direct no-expansion, foreign siblings/events, partial/reordered/mutated/non-uniform fallback, reuse/generation handling, stale/abort, PAPI before/after faults, and terminal disposal.
    • Lynx package: 25/25 files, 350/350 tests.
    • Scoped production typecheck and packages/lynx/tsconfig.testing.json: pass.
    • Benchmark instrumentation Node test, targeted Prettier, pnpm sync, and git diff --check: pass.
    • Full concurrent suite: 2,190/2,193 files and 21,588/21,603 tests passed; all 15 fixed-timeout/Vite-504 failures passed when isolated (CLI 8/8, website MCP 9/9, browser native-change 12/12).
    • Draft PR current head: lint/typecheck successful; Cursor Bugbot successful with no inline findings.

    Rejected avenues / measured floor

    • Bulk __ReplaceElements: 321.890 ms vs 312.695 ms control; Web Core still loops DOM removals internally.
    • Reverse roots: 343.535 ms vs 312.695 ms; PAPI span regressed.
    • Packed roots / four-way unroll: only 0.0015 / 0.0127 ms saved per 10,000 calls.
    • Text-host fusion has no safe public Lynx authoring/Octane identity boundary and was not used as a benchmark shortcut.

    The remaining dominant owner is the shared 10,000-call PAPI/DOM removal floor.

    Artifacts

    The archives were decompressed and compared semantically with their source runner JSON; all nine archive hashes and all 16 baseline/candidate bundle hashes were verified. The post-merge featured refresh remains intentionally after maintainer merge.

    This iteration and comment were agent-authored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-authoredenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions