Skip to content

perf: inline fixed-arity event bundle arguments - #995

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fixed-arity-event-bundles-981
Sep 8, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fixed-arity-event-bundles-981

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Store compiled one- and two-argument event callback captures directly on the nominal handler bundle, removing their separate argument arrays.
  • Keep the args slot as a numeric arity tag on these two shapes so the shared dispatch read stays in its existing offset. Arity zero retains its shared empty array; the variadic path retains an array.
  • Preserve the queued callback and its original arguments during synchronous dispatch, and restore the complete bundle after a suspended root render rolls back.

Why

The runtime currently retains one additional array per evt1/evt2 handler, including two such handlers on each keyed js-framework row. Updates also journal the bundle and its mutable argument array separately. This specializes only the fixed arities and leaves the compiler call ABI unchanged.

Changes

  • Inline a0/a1 fields in evt1/evt2, update them in place, and journal only the bundle for rollback.
  • Snapshot scalar fields for queued handlers before an in-flight update; dispatch array bundles on their original path and scalar bundles by the numeric arity tag.
  • Add public event regressions for one/two-argument queued callbacks and a held-root rollback/retry, plus an octane patch changeset.

Validation

  • Exact production-runtime Node 26/V8 14.6 post-GC A/B, 150,000 retained instances per arity in fresh paired subprocesses: evt1 112.13 → 64.11 bytes and evt2 120.10 → 72.06–72.10 bytes per bundle, including the retained reference slot. evt0 and evtN are unchanged. All candidate maps remain fast; the one shared baseline bundle map becomes three maps.
  • Chromium 149 source-only production-runtime A/B on the same machine, four warmups and eight mirrored ABBA cycles: 1,000-row keyed mount 1.80 → 1.80 ms; 10,000-row mount 15.75 → 15.85 ms (within sample variance). Each cycle verified native click arguments, a synchronous queued old/new handler snapshot, row order, survivor identity, and detached cleanup. The full-index bundle is +149 raw / +22 gzip / −29 Brotli bytes. No compiled application speedup is claimed.
  • A 2.1M-call source-only mixed-arity dispatch proxy measured 12.10 → 11.85 ms with the array-first branch; a number-first shape regressed and was rejected. Proxy results are not an application timing claim.
  • Source-only cached-compiler executions of the new queued-handler and suspended-root scenarios passed. Temporarily removing preserveDispatchedBundle or journalObjectOnce from the scalar update paths turned the corresponding scenario red. Pinned current-head CI passed all 26 jobs at 19c829d16831a1e3d59a862838f380dddffccb94; audit-events-portals.test.ts passed 20/20 tests in both octane and octane-prod. Typecheck, Chromium, and parity passed. The initial parity run had an asynchronous upstream Dialog act(...) warning that did not recur on the identical-head retry.
  • Cached Prettier check for changed TS and changeset, git diff --check, standalone version generator, and package inventory check (122 publishable packages).
  • Pinned PR-head targeted Bench and latest-main baseline passed event-delegation correctness/work gates and built bundle-size, but both jobs failed the exact same 55 pre-existing bundle-size ratio guards, with no new guard breach. On the pinned toolchain the Octane TSRX framework bundle is +171 raw / +65 gzip / +48 Brotli bytes (84,668/28,323/25,278 → 84,839/28,388/25,326). Two-sample event timings across separate hosted VMs moved for every framework and cannot isolate this PR. Only the fork-only workflow differs from PR/main source; package source, benchmarks, and lockfile were pinned to their respective commits.
  • pnpm sync could not reach the generators locally: the configured registry returned 403 for pinned @tsrx/[email protected] after lockfile policy checks. Prior automatic approval review rejected fetching this package directly from the public registry as a bypass. Current-head CI validated generated files and the pinned test suite.

Risk / follow-ups

The extra arity distinction adds two bundle maps and a dispatch type branch; same-machine mixed-dispatch measurements were neutral, while real keyed DOM mount timings overlapped noise. The source-only browser harness does not establish a whole-app speedup. The two public tests cover the otherwise subtle reentrant and rollback semantics. This follows merged #991 and #992 and addresses the fixed-arity argument-storage suggestion in #981.

Refs #981.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@domgan-oai
domgan-oai marked this pull request as ready for review September 8, 2026 14:07
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Sep 8, 2026
@domgan-oai
domgan-oai merged commit fbbb53d into octanejs:main Sep 8, 2026
69 of 76 checks passed
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.

1 participant