Skip to content

perf(core): look up the root only for composition elements when sizing a clip window - #6361

Merged
miguel-heygen merged 1 commit into
mainfrom
perf/root-lookup-only-for-compositions
Oct 26, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
perf/root-lookup-only-for-compositions

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

runtimeElementWindow looks up the root composition only for elements that carry data-composition-id. Every other timed node skips the lookup.

Why

#6354 made the root's clip window open-ended and decided "is this the root" with findRootCompositionElement. That lookup ran for every timed node, and for every timed ancestor clipChainVisibleAt walks, on every visibility pass. Each call is one or two document-wide querySelectors, and without [data-root="true"] the first one scans the whole document. So a full pass (every renderSeek frame) grew roughly as timed nodes × DOM size. Only a data-composition-id element can be the root, so other nodes never need the query. Raised in review of #6354 after it had been queued.

How

const isRoot = compId !== null && rawNode === findRootCompositionElement(rawNode.ownerDocument); Same result for every node, with no query for the non-composition ones.

Test plan

Small on purpose: a one-line follow-up to #6354's review, kept apart so it lands on its own.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 132 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE · 0 blocker · 0 important · 0 nits · head 5de45c8a

This is exactly equivalent to the old check. findRootCompositionElement only returns elements that match [data-composition-id], so a node without that attribute could never equal it. !== null (rather than a truthy check) keeps an empty data-composition-id="" root working. CI is green.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit b054bb9 Oct 26, 2026
82 checks passed
@miguel-heygen
miguel-heygen deleted the perf/root-lookup-only-for-compositions branch October 26, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant