Skip to content

[lynx-perf-live 4] Make keyed moves topology-only on the wire #46

Open

Description

@Huxpro

Classification

Performance enhancement in the Lynx keyed-reorder transport and host-application path.

Evidence

Exact same-machine featured run at live upstream 9b147781c9b4ec4df053a059633978ddc0ed922a:

  • Octane swap@1k: 50.84 ±2.80 ms
  • ReactLynx: 25.02 ±3.69 ms
  • Vue cells: 16.86–18.80 ms
  • Octane total BTS↔MTS wire: 54,907 B
  • React/Vue total wire: 640–932 B
  • Octane sampled MTS CPU: 56.657 ms

The operation swaps rows 1 and 998 while preserving every keyed row and its observable identity. The result is stable and has zero DNF. Evidence: raw featured run and benchmark PR.

Contract

A keyed reorder guarantees final order and survivor identity. It does not guarantee React's physical move set or any exact internal move count. The optimization gate may measure commands/bytes, but behavioral tests must assert order, identity, live events/refs, and cleanup rather than private reconciler steps.

Hypothesis

The retained keyed rows are not doing useful application work proportional to 1,000 rows, but the transported batch or main-thread preparation may still publish broad topology, attachment, lifecycle, or public-handle state. The 54.9 KB payload for a two-row reorder is the first owner to explain; do not assume the LIS reconciler is at fault before capturing the actual batch.

Investigation

  1. Extend the deterministic lynx-table gate with swap: command histogram, serialized bytes by direction, Row body renders, handle/list-ancestry deltas, and final survivor identities.
  2. Attribute background replay/staging, wire clone/transfer, main-thread validation/prepare/apply, PAPI moves, acknowledgement, and presentation.
  3. Prove whether cost scales with moved top-level hosts or total retained rows by running 1k/10k/30k controls with the same two-row swap.
  4. Only after attribution, evaluate topology-only move encoding, narrower attachment publication, or compact completion on the owning layer.
  5. Keep mixed-version peers, portals, lists, lifecycle callbacks, refs, worklets, rejection, rollback, and stale generations on their explicit safe paths.

Acceptance

  • same-machine forward and reverse runs both improve swap@1k by at least 25% and bring the candidate within 1.5× the five-entry React/Vue median;
  • swap wire is at most 2 KiB and scales with moved top-level hosts, not total retained rows;
  • deterministic counters prove unchanged rows do not render or republish host/public state;
  • final DOM order, survivor DOM/host identity, focus, delegated events, refs, lifecycle callbacks, and fault rollback pass;
  • create, replace, append, remove, clear, update/select, storms, startup/FCP, heap, and Web/Lynx gzip have no >5% adverse decision cell;
  • every timing claim uses the same machine, build inputs, semantic result, warmup, and forward/reverse order.

Non-goals

  • Do not pin an exact physical move set; Octane's LIS reconciler may choose any valid minimum-compatible placement sequence.
  • Do not special-case the benchmark indices or row component.
  • Do not trade keyed identity, events, refs, focus, or rollback safety for a smaller packet.

Provenance

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

Activity

  1. Huxpro commented on Aug 11, 2026

    @Huxpro
    OwnerAuthor

    Review update after #43–#45

    Decision: keep this issue open; its contract and acceptance thresholds remain valid, but reset its measurement base after the accepted upstream candidates are integrated.

    • #43 / upstream #706 specializes only a fully certified dense-run teardown. It intentionally leaves the 100,000-command clear wire stream unchanged and does not introduce a keyed-move representation. Its teardown certificate must not be reused for live reorders, whose survivor identity and lifetime semantics are different.
    • #44 / upstream #707 removes optional worklet machinery from the no-worklet main graph. It changes neither keyed topology nor swap transport.
    • #45 deterministically shows that a 33% message-count reduction is not, by itself, a wall-clock owner. Compact ACK/message count is therefore not an authorized primary experiment here unless measured ACK/clone time reaches the issue's attribution gate.

    Execution plan

    1. Do not develop against the historical 9b147781 result directly. After perf(lynx): specialize compact run teardown octanejs/octane#706 and perf(lynx): keep optional worklet runtime cold octanejs/octane#707 land (or on an explicit integration commit containing their final SHAs), rebuild the exact featured benchmark and record the new Octane bundle hashes. Re-run every ReactLynx/Vue reference entry from the same lockfile and host; keep those rows as controls rather than copying the earlier table.
    2. Add the deterministic swap cell first: both-direction bytes/messages, command histogram, handle/list-ancestry/attachment deltas, Row renders, survivor identities, and final checksum at 1k/10k/30k.
    3. Split wall time into BTS replay/staging, serialization/clone, MTS validation/prepare/apply, PAPI moves, ACK, and presentation. A product change starts only when one directly measured stage owns at least 10% of swap time and scales with retained rows.
    4. Prefer the narrowest owner: suppress broad attachment/public-handle publication if that is the payload; add a topology-only move encoding only if the captured batch proves topology is still the owner. If the post-stack 54.9 KiB residual disappears, close or rewrite this issue rather than forcing a protocol change.
    5. Run the candidate AB/BA at 1k/10k/30k, then the full regression matrix in both orders. Keep the existing >=25%, <=2 KiB, identity/focus/event/ref, and no >5% adverse cell gates unchanged.

    Official baseline remains pending until the upstream candidates merge; gzip deltas from octanejs#706 and octanejs#707 are non-additive and must not be combined arithmetically.

  2. Huxpro commented on Aug 12, 2026

    @Huxpro
    OwnerAuthor

    Executed against the required post-octanejs#706/octanejs#707 stack and then re-based/revalidated on real upstream main after both PRs merged (ffadd397).

    Upstream draft PR: octanejs#716
    Published head: 50ddc5c8ea315c712d1974db73e06229408fc41f

    Decision

    GO. The universal keyed planner was the observed owner for far swaps. The submitted O(n log n) LIS planner reduces a 1,000-row far swap from 997 move commands / 47,986 bytes to 2 moves / 368 bytes. The two-move result also holds at 10k and 30k, with zero row renders, survivor identity preserved, and events still routed to the correct rows.

    Exact live v2 evidence

    order baseline swap candidate swap delta records / DNF
    forward 51.465 ms 26.8 ms -48.0% 802 / 0
    reverse 52.73 ms 26.2 ms -50.3% 802 / 0
    • forward artifact: 2026-08-11T23-22-41-65160668d8d9-issue46-lis-v2-featured.json
    • reverse artifact: 2026-08-11T23-49-03-65160668d8d9-issue46-lis-v2-featured-reverse.json
    • create, replace, append, and clear remain within the v1 regression envelope in both orders
    • a reverse-placement prototype was rejected because it regressed replace/append by 20–32%; the PR uses forward placement anchored to the next stable survivor

    Bundle and validation

    Latest-main rows=0 delta:

    • Web: +595 raw / +257 gzip bytes
    • Lynx: +595 raw / +251 gzip bytes

    Passed:

    • 106 universal event/host/reconciler tests
    • Octane package typecheck
    • 24/299 applicable Lynx-table ratio guards
    • exact forward/reverse v2 live runs, zero DNF
    • formatting and pnpm sync

    The current dirty worktree was not modified; the issue was implemented in an isolated worktree/branch.

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