Skip to content

perf: compact delegated handler bundle literals - #991

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

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/event-bundle-layout-981

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Put the private computed Symbol brand last in all four delegated handler bundle factories and the in-flight dispatch snapshot.
  • Keep handler function/argument storage, update behavior, and dispatch semantics unchanged.

Why

The earlier Symbol-first literal prevents V8 from building fn and args into its object-literal boilerplate. Each event-enabled compiled row typically mounts two bundles. On current main, the exact production evt1 output uses three keyed property definitions and retains a 56-byte bundle; the reordered literal uses two named definitions plus the Symbol and retains a 48-byte bundle.

Changes

  • Reorder five internal HandlerBundle literals and document why the computed brand is last.
  • Extend the public compiled event regression to cover 0/2/N-argument callbacks, a synchronous child update during dispatch, the queued ancestor's old handler/args, and the next event's new handler/args.
  • Add an octane patch changeset.

Validation

  • Source-only delegated DOM/JSDOM harness passes with the candidate and turns red when the evt2 bundle brand is deliberately omitted in memory. The compiled event suite passed all 18 tests in both octane and octane-prod on CI.
  • Exact esbuild 0.28.1 production evt1 V8 probe (Node 26/V8 14.6): 72 → 64 bytes of bytecode, 3 keyed definitions → 2 named plus 1 keyed, 56 → 48 bytes per fast-property bundle. Two hundred thousand retained bundles use 1.6 MB less heap. Own keys/descriptors and brand values match.
  • Same-environment Chromium 149 keyed mount on Apple M5 Max, 4 warmups and 8 mirrored ABBA cycles: two handlers per row, native click arguments/order, keyed survivor identity, synchronous in-flight update snapshot, and detached cleanup checked. The 10,000-row median was 16.9 → 15.4 ms, faster in all eight paired cycles. Absolute timings varied across runs and one cycle had a system outlier; this is directional source-only evidence, not the canonical compiled js-framework score.
  • Full-index production bundle: 343,515 raw bytes unchanged; gzip 108,231 → 108,233 bytes; Brotli 92,474 → 92,398 bytes.
  • Cached Prettier on changed files, esbuild TypeScript parse, git diff --check, and source-only public-event probe.
  • Current-head CI: all 26 jobs passed, including both event test modes, lint, typecheck, integration, parity, and provenance.
  • Local pinned Vitest/typecheck and pnpm sync could not start after the dependency registry returned 403 during the frozen install.

Risk / follow-ups

Literal field evaluation order changes only among internal parameter reads and constants; JS own-key order and property descriptors match. Fixed-arity args arrays still allocate, so the separate #981 suggestion to store those arguments as fields remains open. A compiled js-framework benchmark remains useful before making a broad application-speed claim.

Refs #981. Follows merged #990.

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.


Note

Low Risk
Internal literal field order only; semantics and property descriptors are unchanged, with new tests locking in sync-dispatch snapshot behavior.

Overview
Reorders delegated event HandlerBundle object literals so fn and args come first and the private Symbol brand is last, in evt0–evtN and in preserveDispatchedBundle dispatch snapshots. Runtime comments explain this helps V8 use object-literal boilerplate and cuts retained bundle size (e.g. smaller per-bundle footprint at scale) without changing mount/update or dispatch behavior.

Adds a compiled-event regression that clicks through capture/bubble with multi-argument handlers and a synchronous child update during dispatch, asserting queued ancestors still see old fn/args and the next click sees the new ones. Includes an octane patch changeset.

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

@domgan-oai
domgan-oai marked this pull request as ready for review September 8, 2026 12:14
@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 890527f into octanejs:main Sep 8, 2026
46 of 49 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