Skip to content

perf: Lock-free root fast paths for hygiene queries - #160494

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
xmakro:perf/hygiene-root-fastpaths
Aug 6, 2026
Merged

perf: Lock-free root fast paths for hygiene queries#160494
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
xmakro:perf/hygiene-root-fastpaths

Conversation

@xmakro

@xmakro xmakro commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

normalize_to_macros_2_0, normalize_to_macro_rules and outer_expn_is_descendant_of take the HygieneData lock even for the root syntax context, the common case, where the answer is fixed: the root normalizes to itself, and everything descends from the root expansion. This PR avoids the lock, like the existing fast paths in ExpnId::is_descendant_of.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 4, 2026
@petrochenkov petrochenkov self-assigned this Aug 4, 2026
@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 4, 2026
@petrochenkov
petrochenkov marked this pull request as ready for review August 4, 2026 10:26
@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

@petrochenkov

Copy link
Copy Markdown
Contributor

Yeah, it's good to apply this fast path consistently.
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 4, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
perf: Lock-free root fast paths for hygiene queries
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 4, 2026
@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 51cbd2b (51cbd2b75321f7f1e1ca27962356a92e2d7f1d9e)
Base parent: c9ff496 (c9ff496891c278ad660bc0ab85c1f0b72059464a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (51cbd2b): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.6%, -0.2%] 75
Improvements ✅
(secondary)
-0.8% [-2.2%, -0.2%] 39
All ❌✅ (primary) -0.3% [-0.6%, -0.2%] 75

Max RSS (memory usage)

Results (secondary -0.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.7% [4.7%, 4.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.4% [-5.0%, -1.8%] 2
All ❌✅ (primary) - - 0

Cycles

Results (primary -0.3%, secondary -0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.2% [0.4%, 2.6%] 7
Regressions ❌
(secondary)
1.3% [0.7%, 1.7%] 4
Improvements ✅
(primary)
-2.0% [-7.0%, -0.4%] 6
Improvements ✅
(secondary)
-1.2% [-3.1%, -0.4%] 6
All ❌✅ (primary) -0.3% [-7.0%, 2.6%] 13

Binary size

Results (primary -0.1%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 75
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 39
All ❌✅ (primary) -0.1% [-0.1%, -0.0%] 75

Bootstrap: 489.838s -> 496.142s (1.29%)
Artifact size: 390.28 MiB -> 390.17 MiB (-0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 4, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7c901eb has been approved by petrochenkov

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

Reason for tree closure: manually handling queue due to backlog

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 4, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 6, 2026
@rust-bors

rust-bors Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: petrochenkov
Duration: 3h 12m 55s
Pushing f73951d to main...

@rust-bors
rust-bors Bot merged commit f73951d into rust-lang:main Aug 6, 2026
15 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 26bfbf2 (parent) -> f73951d (this PR)

Test differences

Show 18 test diffs

18 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard f73951df0a5566d94d13b7954acd9f4ab1fa3734 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-gcc: 41m 54s -> 1h 14m (+76.7%)
  2. x86_64-gnu-gcc-core-tests: 8m 20s -> 14m 44s (+76.6%)
  3. i686-msvc-1: 1h 49m -> 2h 57m (+62.8%)
  4. dist-i586-gnu-i586-i686-musl: 16m 54s -> 24m 41s (+46.0%)
  5. test-various: 1h 33m -> 2h 5m (+33.9%)
  6. x86_64-msvc-ext2: 1h 54m -> 1h 23m (-27.3%)
  7. dist-powerpc64le-linux-musl: 1h 14m -> 1h 34m (+26.3%)
  8. optional-x86_64-gnu-autodiff: 43m 35s -> 54m 54s (+26.0%)
  9. dist-powerpc64-linux-musl: 1h 32m -> 1h 9m (-25.0%)
  10. x86_64-msvc-1: 2h 36m -> 1h 58m (-24.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (f73951d): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.7%, -0.2%] 61
Improvements ✅
(secondary)
-0.8% [-2.3%, -0.1%] 42
All ❌✅ (primary) -0.3% [-0.7%, -0.2%] 61

Max RSS (memory usage)

Results (primary 2.5%, secondary 6.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.5% [2.5%, 2.5%] 1
Regressions ❌
(secondary)
6.1% [6.1%, 6.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.5% [2.5%, 2.5%] 1

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 459.691s -> 460.81s (0.24%)
Artifact size: 398.70 MiB -> 398.76 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants