perf(react_compiler): compare value set pointers before probing in state merge#24805
Merged
Boshen merged 1 commit intoJul 22, 2026
Merged
Conversation
…llocation The inference state's per-variable value sets are immutable and shared via `Rc`, so at most joins both incoming states hold the very same set. In that case the other side can't contribute a new value, yet the merge still ran the "does other add anything" probe over the whole set for every variable. Compare the pointers first and skip the scan when they match. Both merge routines were spelling that probe differently, so it now lives in one helper. Behaviour is unchanged: a shared allocation always has identical contents, and the sets are never mutated in place.
Merging this PR will not alter performance
Comparing Footnotes
|
Contributor
Author
|
cc: @Boshen for React Compiler performance |
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.
Context
Value sets in the aliasing inference state are
Rc<FxHashSet<ValueId>>, shared between states rather than copied (#24117). When two states meet at a join, the merge still walks every variable and probes one set against the other looking for a value the current state doesn't have. Most of the time both sides point at the sameRc, so that probe is comparing a set to itself.This PR
Check
Rc::ptr_eqbefore probing. If the pointers match there is nothing to add, so we skip the scan. Both merge paths did this check in slightly different ways, so I pulled it into one helper. The sets are never mutated in place, which is what makes the pointer check safe.Performance
This PR was assisted by Claude Code.