Repository navigation
perf: preclassify compiled DOM event categories - #1972
Conversation
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
1 other measured values are unchanged. Public-import reachability bundles (bytes)
30 other measured values are unchanged. |
|
Good to go, with one cleanup nit and one follow-up worth considering. Classification is unchanged, and every path that can't be classified at compile time still uses the runtime classifier.
Trivial: the comment at Merge note: the conflicts with #1966 and #1967 are adjacent insertions at the top of Verified:
|
Summary
Classify statically authored DOM events during compilation so applications can omit the runtime event-category tables. Dynamic event props and the public registration APIs continue to classify names at runtime. Both paths share the existing event record and listener installers, preserving capture/bubble ordering, late registration, root/portal ownership, and native controlled-input behavior.
The compiler uses private client imports and collision-safe aliases. Server, universal and Valdi output retain their existing contracts; explicit DOM targets and DOM native reads use the same specialization. Component-owned registration and module-prelude ordering are preserved. The staged-DOM scanner and descriptor-event benchmark retain their existing ownership boundaries after the source move. The eval sandbox bridge exposes only the two new compiler helpers, and the Rsbuild hot-module fixture resolves the private client ABI through its existing callable mock.
Matched complete production JavaScript against
4cc2a1ed700318846c8d93249550122bc86e3dfa, with Node 24.20.0 and the existing configurations:Totals include all emitted JavaScript assets. Final production assets are hash-identical to the measured candidate. The classification tables disappear from the static TSRX fixture and remain in the dynamic JSX/API controls. The latter have small raw growth despite compressed savings.
Validation
pnpm format:check— full workspace not run; explicit changed-file checks pass.pnpm typecheck— full workspace not run; runtime, public index and event declarations pass the scoped check. The selected test program reports exactly the same nine diagnostics on baseline and candidate: the existing@tsrx/coredeclaration gap and existing callbacks in its compiler test. No additional diagnostics remain.pnpm test— full workspace not run.pnpm sync; all 255 production files and the reviewed diff remain unchanged. Signed local commit verified.070e690a800a60fda8cad478c96655fdc7a771e2; no unresolved current review threads. The PR is ready and mergeable. The distinct CI timing observation and completed bounded follow-up are disclosed below.Risk / follow-ups
The current-head CI benchmark reports a strictly positive JSX swap paired ratio of 1.05229 [1.02595, 1.09839] (30 pairs). Its displayed aggregate scores are 0.166 → 0.171 ms; their quotient is not the paired-ratio estimator. The repository’s “within noise” label does not establish equivalence. The earlier
a3b505b0and4f9d2478reports, produced from the same 255 production source files, are preserved; their more neutral results do not disprove the latest observation. All 64 work counters remain equal, which does not establish latency. One bounded matched fresh-group JSX swap follow-up is complete below; it did not reproduce a statistically resolved slowdown, but does not disprove this CI observation.The one prespecified local JSX swap follow-up retained all 32 fresh-browser groups (16 candidate and 16 identical-code controls), 320 warmup + 384 measured pairs and 32 separate first-swap pairs. Its independent group-mean comparison is 1.01215 [0.98044, 1.01767]: no statistically resolved local slowdown, with an upper bound of +1.77%. The identical-code control is narrowly positive, 1.00992 [1.00010, 1.02134], and has positive creation/execution-order partitions. All observations remain included; no control normalization or repeat was used to remove those effects. This limits attribution and does not establish equivalence or disprove the original CI observation under its different host/history.
The local comparison reused the frozen ordinary esbuild/no-split production assets, original swap operation and all 1,000 survivor/text checks. Both sides used the same odd repeat within each group (149–183); retained windows were 23.875–37.685 ms. First swaps, taken after the original three mount/clear warmups but before any swap warmups, were recorded separately: candidate 0.97202 [0.93301, 1.01980] at approximately 0.950–1.360 ms. This is a fresh-operation check, not cold-start or full preceding CI history. All source/artifact, clock, style and seeded-input gates passed. No additional swap run or source change followed this result.
Static registration emits an additional numeric array and both registration paths call a shared installer once per newly registered phase. This transfers classification to compilation and changes cold registration work; dispatch bodies and event-record shapes are unchanged.
Local warmed root-lifetime timing is inconclusive: candidate/base 1.00485 [0.95886, 1.02927], with a 95% upper bound of +2.93%; the identical-code control is 1.01188 [0.98663, 1.03214]. Both cohorts have strong creation/execution-order effects. Positive candidate partitions remain recorded, including baseline-created-first 1.02258 [1.01526, 1.03463] and candidate-executed-first 1.08006 [1.02839, 1.12217]. These are not discarded or proved to be noise, and root performance equivalence is not established.
The local portal-lifetime lane is 0.97721 [0.97067, 0.98667], with identical control 0.99558 [0.98502, 1.00837]; this does not imply an application-wide speedup. First-cycle estimates are coarse: root 0.98857 [0.78723, 1.22653] at approximately 0.150–0.275 ms, portal 0.94251 [0.92708, 1.06707] at 0.810–1.080 ms. Import measurements include chunk loading, parsing and evaluation, so there is no isolated classification or cold-start guarantee.
The initial calibration cap was too small to reach the 20 ms target on both sides; its slower candidate root sample (baseline/head 19.110/23.225 ms) is preserved. A reviewed cap-only increase selected common repeats of 5,103 root cycles and 2,566 portal cycles before collection; its root calibration was also directionally slower (22.080/23.415 ms). Retained windows subsequently ranged 15.615–34.080 ms for roots and 11.780–16.355 ms for portals. No repeats were retuned or samples excluded after collection.
This is a scoped bundle reduction with finite local evidence, not a universal performance guarantee or completion of the broader bundle-size target. Current-head CI is green and the single JSX swap follow-up is complete with the limits above. Joint latency for the broader combined bundle-reduction candidate has not been qualified by this individual PR.
Provenance
agent-authored)Origin: Codex task, implementation subtask
duplication_audit, hostcom-79386. Key choices: fixed baseline, shared category definition and existing event record, private DOM-only compiler ABI, independently reviewed source/correctness with matched complete-bundle and production-work evidence; local latency uncertainty, the distinct CI observation and the bounded JSX swap follow-up remain explicit; current-head CI is green.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes core delegated event registration and classification paths used for capture/bubble ordering and React-parity dispatch, though behavior is heavily regression-tested and dynamic APIs remain.
Overview
Preclassifies statically authored DOM event handlers at compile time so production bundles can skip shipping the runtime event-category tables, while dynamic registration (
delegateEvents/delegateCaptureEvents) still classifies names when modules load.Event category bits and
delegatedEventFlags()move intoevent-names.js(shared by compiler and runtime). For eligible DOM client output, the compiler emits__delegateEvents/__delegateCaptureEventsviaoctane/internal/clientwith parallel name + flag arrays; explicit__runtimeImportRoutesand non-DOM targets keep the public registration ABI. Runtime registration is refactored around sharedregisterDelegatedBubble/registerDelegatedCaptureinstallers that read stored flags on eachDelegatedEventTypeinstead of re-deriving capture/target-only/discrete behavior from the event name.Tests and tooling follow the new contract: registration lifetime/propagation cases, helper-alias shadowing for the
__helpers, private-runtime import boundaries, eval sandbox re-exports, staged-DOM ownership keys, and the descriptor-events benchmark’s catalog probe scoped toisDelegatedEventProp.Reviewed by Cursor Bugbot for commit 545ffd0. Bugbot is set up for automated code reviews on this repo. Configure here.