Skip to content

perf(lynx): compact sparse slot set runs - #418

Merged
Huxpro merged 1 commit into
new-lynxfrom
huxcx/m4-set-run-delta-291
Sep 30, 2026
Merged

Huxpro merged 1 commit into
new-lynxfrom
huxcx/m4-set-run-delta-291

Conversation

@Huxpro

@Huxpro Huxpro commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • add delta protocol v3 SET-RUN(first, stride, slot, values…) for consecutive equal-slot writes over an arithmetic instance sequence
  • compact only runs of at least three writes and preserve operation order, sparse instance identity, scalar encoding, transaction rollback, and zero-copy behavior when no run is found
  • stream SET-RUN directly through the main-thread resident store and preserve background-worklet retain/reject/accept/clear ownership per addressed slot
  • document the protocol amendment and add encode/decode, compaction-boundary, rollback, and worklet-lifecycle regressions

Attribution and mechanism

The frozen M4 candidate's remaining Vue Vapor default blocker was update10th@10000: candidate/comparator median ratio 1.07997 [1.06721, 1.09195]. Owner evidence split the candidate cost across both realms: BTS CPU 12.286 ms vs 5.361 ms, MTS CPU 219.249 ms vs 224.839 ms, and MTS wire 38,626 vs 35,226 bytes.

That workload emits 1,000 consecutive writes to the same compiled row slot with an instance stride of 10. This change represents that exact sequence as one SET-RUN instead of 1,000 independently framed SET operations. Non-consecutive, mixed-slot, descending, and runs shorter than three retain the prior representation; the producer's no-hit path returns the original operation array without an extra copy.

Production evidence

Baseline: merged new-lynx@f3e33a7a6dad78ada5ee4277f85f4b26255cd48f
Candidate: 5826addaf73e820c43b98359e152bdb6998cf5d5

Production bundle identities rebuilt from the committed source:

  • baseline Web: 203,828 B, ec8a9e19bfe12cc5930654f9d590bceb7dc8209b429ef16eb93829c1567455aa
  • candidate Web: 204,842 B, 51cc3ac6b5ab9ab4fd97058cd9f2550b2353eba3b825fed261fc995e9523263f (+0.50%)
  • baseline Lynx: 210,147 B, d67c9b5df350cb541d09f250d0d28d57325e571c2b81df88e50cd64b551d9298
  • candidate Lynx: 211,193 B, 1f3e473a4f5f501406f62c93bf0ffe7088e796ae7edfb5e3acea878d18c026e1 (+0.50%)

Two independent 20-repetition production Web AB/BA windows on update10th@10000, zero DNF/failure and no outlier deletion:

Metric, candidate / baseline AB BA two-window geometric ratio
wall median 0.94761 0.91382 0.93056
BTS CPU median 0.90492 0.86217 0.88329
MTS CPU median 0.97707 0.94663 0.96173
BTS bytes / messages 1.00000 / 1.00000 1.00000 / 1.00000 1.00000 / 1.00000
MTS bytes / messages 0.70579 / 0.66667 0.70579 / 0.66667 0.70579 / 0.66667

Raw screening run SHA-256 values:

  • AB: 809e9302d46b4306361b8870780159278b012cd5e410665ea70e5a906cede709
  • BA: a608c28bda1d5d131fe435929dca345690fbdbf661a1580e48923edecdb0503a

Direct same-window Vue Vapor default screening crossed the prior failing wall cell in both orders: 0.99408× and 0.99967×, geometric ratio 0.99687×; MTS CPU was 0.94480× and MTS bytes 0.77392×. This is not promoted to formal #291 acceptance: the merged SHA still needs the predeclared 40-session / 800-sample-per-arm median+p95 replication. Costs also remain explicit: BTS CPU was 2.049×, BTS bytes 1.629×, and BTS messages 1.333× versus Vapor.

Direct-comparator raw screening SHA-256 values:

  • AB: 64b0199b446795514b352d9ccfc899e9c8e652dc535bb52a4c7a745ca13c8974
  • BA: 851a01b0bd851ecd3617b2d1242deead7cb38ec51779dced7cf76d9e0cbc7ac8

The raw run files and immutable merged-head artifact will be preserved in Huxpro/lynx-js-framework-benchmark#73 before formal qualification; the numbers above are source-branch screening only.

Validation

  • pnpm sync
  • pnpm format:files:check (changed files)
  • pnpm typecheck:files (changed implementation/tests)
  • all packages/lynx/tests: 78 files / 1,187 tests passed
  • focused protocol/producer/frame/worklet suite after final test addition: 4 files / 69 tests passed
  • git diff --check
  • final production Web/Lynx rebuild reproduced the hashes above
  • current-head CI

Part of #291.

Provenance

  • An agent produced this diff (agent-authored)

Adds an arithmetic SET-RUN delta opcode that removes repeated sparse-list update framing, cutting the remaining 10k update wall time by 6.9%, BTS CPU by 11.7%, MTS CPU by 3.8%, and MTS wire bytes by 29.4% in balanced production screening while preserving rollback and worklet ownership.

@github-actions
github-actions Bot marked this pull request as draft September 30, 2026 18:57
@Huxpro
Huxpro marked this pull request as ready for review September 30, 2026 19:03
@Huxpro
Huxpro merged commit c288921 into new-lynx Sep 30, 2026
11 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant