Repository navigation
perf: avoid repeated delegated event paths - #1016
Merged
domgan-oai merged 1 commit intoSep 9, 2026
Merged
domgan-oai merged 1 commit into
domgan-oai merged 1 commit into
Conversation
Closed
68 of 84 tasks
domgan-oai
marked this pull request as ready for review
September 9, 2026 14:10
14 of 21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
composedPath()in the root capture observer when one public root has no portals and no authored capture path is needed; retain the root epoch stamp.playevent.Addresses the delegated
composedPath()finding in #981. Keep the issue open for its remaining checklist items.Validation
pnpm typecheckpnpm format:files:checkon all changed files;pnpm syncgenerated no tracked changesnode benchmarks/event-delegation/work.mjsin Chromium: no-authored-capture inputs 256 → 128 path calls for 128 events; nonbubblingplay3 → 1. Authored input capture remains 256/128 events, with portal, handler order, controlled output, and native propagation controls passing on both main and candidate.node benchmarks/bench.mjs --quick event-delegationbefore and after: captured-input timing 14.4 ms → 8.4 ms in two-sample quick runs; other framework timings moved too, so no throughput gain is claimed.pnpm test: attempted locally on Node 26; the long multi-project run reported unrelated timeouts and Node 26 localStorage failures, then exhausted its 4 GB V8 heap. Isolated Jotai utils passed 10/10 and compiler/Volar passed 26/26 on supported Node 22. The email preview watcher test fails identically with the unmodified main runtime on this host. Current-head CI on Node 24 is the full-suite gate.Risk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core delegated event propagation in the runtime; behavior is constrained to single-root/no-portal and path-reuse paths but incorrect path timing could break capture/bubble ordering or nested roots.
Overview
Reduces how often Octane calls
Event.prototype.composedPath()during delegated event delivery, which was a hotspot for simple apps with one root and no portals.In
prepareDelegatedEvent, when there is a single delegation root and no portals, the root capture observer now only stamps the root epoch and returns without building a path; bubble handling can construct the path once after native target listeners run. For nonbubbling events that share one native capture callback,dispatchDelegatedpasses the same path into capture and emulated bubble (buildDelegatedPath) instead of callingcomposedPath()again. Multi-root, portal, and authored-capture cases still prepare paths eagerly when needed.Benchmark and test coverage adds a separate
event-work-no-captureproduction fixture (no authored input capture at module load), extendswork.mjsto assert onecomposedPathper input on that path and one per nonbubblingplayevent with correct handler order, and adds regressions for capture-time remounts onplayand nested-root bubbling after inner remount.Reviewed by Cursor Bugbot for commit 937fc52. Bugbot is set up for automated code reviews on this repo. Configure here.