script: Don't always allocate NodeRareData when accessing WeakRangeVec - #46440
Merged
Conversation
…eVec` Previously the code would eagerly allocate `NodeRareData` when trying to access a Node's `WeakRangeVec` (essentially live ranges) during mutation. Some of the callsites were guarded with calls to `weak_ranges_is_empty`, but others were not. This kind of thing can lead to a lot of extra allocation during DOM mutation. This change splits the getter into one that returns an `Option` and another that ensures that the `WeakRangeVec` and `NodeRareData` exist. In addition, some addition specification text is added naer edit sites. Finally, a similar optimization is done for `remove_mutation_observer`. When there is no rare data there is no mutation observer to remove. This work might be useful if selection tracking is done via live ranges. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
mrobinson
force-pushed
the
weak-ranges-efficiency
branch
from
July 10, 2026 13:45
4407fe3 to
e69435d
Compare
|
🔨 Triggering try run (#29146148354) for Linux (WPT) |
|
Test results for linux-wpt from try job (#29146148354): Flaky unexpected result (38)
Stable unexpected results that are known to be intermittent (15)
Stable unexpected results (1)
|
|
|
Member
Author
|
The failure here seems to be #35935. |
|
🔨 Triggering try run (#29242382438) for Linux (WPT) |
|
Test results for linux-wpt from try job (#29242382438): Flaky unexpected result (46)
Stable unexpected results that are known to be intermittent (19)
|
|
✨ Try run (#29242382438) succeeded. |
TimvdLippe
approved these changes
Jul 13, 2026
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.
Previously the code would eagerly allocate
NodeRareDatawhen trying toaccess a Node's
WeakRangeVec(essentially live ranges) duringmutation. Some of the callsites were guarded with calls to
weak_ranges_is_empty, but others were not. This kind of thing can leadto a lot of extra allocation during DOM mutation. This change splits the
getter into one that returns an
Optionand another that ensures thatthe
WeakRangeVecandNodeRareDataexist. In addition, some additionspecification text is added naer edit sites.
Finally, a similar optimization is done for
remove_mutation_observer.When there is no rare data there is no mutation observer to remove.
This work might be useful if selection tracking is done via live ranges.
Testing: This should not change observable behavior, so is covered by existing tests.