Skip to content

perf(react_compiler): compare value set pointers before probing in state merge#24805

Merged
Boshen merged 1 commit into
oxc-project:mainfrom
mds-ant:perf/react-compiler-merge-ptr-eq
Jul 22, 2026
Merged

perf(react_compiler): compare value set pointers before probing in state merge#24805
Boshen merged 1 commit into
oxc-project:mainfrom
mds-ant:perf/react-compiler-merge-ptr-eq

Conversation

@mds-ant

@mds-ant mds-ant commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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 same Rc, so that probe is comparing a set to itself.

This PR

Check Rc::ptr_eq before 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

workload main this PR delta
3.6k-line control-flow heavy component, instructions 23.762 B 22.034 B -7.3%
same file, wall time 4.55 s 4.13 s -9%
16.5k-file real corpus, instructions (1 thread) 50.135 B 49.697 B -0.87%

This PR was assisted by Claude Code.

…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.
@codspeed-hq

codspeed-hq Bot commented Jul 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 66 skipped benchmarks1


Comparing mds-ant:perf/react-compiler-merge-ptr-eq (f901538) with main (23b904f)

Open in CodSpeed

Footnotes

  1. 66 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@mds-ant

mds-ant commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

cc: @Boshen for React Compiler performance

@Boshen
Boshen merged commit 98f2ecb into oxc-project:main Jul 22, 2026
33 checks passed
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.

2 participants