Skip to content

Hash parent in SyntaxContext - #166636

Draft
aerooneqq wants to merge 2 commits into
rust-lang:mainfrom
aerooneqq:hash-parent-in-syntax-context
Draft

aerooneqq wants to merge 2 commits into
rust-lang:mainfrom
aerooneqq:hash-parent-in-syntax-context

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

We need to hash parent too, otherwise there may be collisions and non-deterministic remappings when parallel AST -> HIR lowering is enabled (#163495). First will try without caching, maybe perf will be ok, if not, will add caches as in expansions.

r? @petrochenkov

@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 Nov 27, 2026
@aerooneqq

Copy link
Copy Markdown
Contributor Author

@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 Nov 27, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 2bbc916 (2bbc91613df48464cce24dae9862fd8aa23c88ac)
Base parent: 063219d (063219d04d8b3428506da3d8585c0221c07ca15b)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (2bbc916): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

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.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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.6% [0.1%, 2.2%] 202
Regressions ❌
(secondary)
0.6% [0.0%, 4.2%] 132
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.2%] 4
All ❌✅ (primary) 0.6% [0.1%, 2.2%] 202

Max RSS (memory usage)

Results (primary -3.6%, 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)
- - 0
Regressions ❌
(secondary)
0.6% [0.6%, 0.6%] 1
Improvements ✅
(primary)
-3.6% [-3.6%, -3.6%] 1
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) -3.6% [-3.6%, -3.6%] 1

Cycles

Results (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)
- - 0
Regressions ❌
(secondary)
1.5% [0.4%, 2.7%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-3.2%, -1.6%] 5
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 461.754s -> 461.589s (-0.04%)
Artifact size: 405.59 MiB -> 405.66 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 27, 2026
@aerooneqq

Copy link
Copy Markdown
Contributor Author

@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 Nov 27, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 60f2ac3 (60f2ac3a5a8bd1de354e6d60f1077f1edff60224)
Base parent: 16bf51a (16bf51a54a6e9065fe045f7cb99c49079a17dcba)

@rust-timer

This comment has been minimized.

@petrochenkov

Copy link
Copy Markdown
Contributor

there may be collisions and non-deterministic remappings when parallel AST -> HIR lowering is enabled

I strongly suspect that this can cause issues without the parallel AST lowering too, they just weren't noticed or tracked to the root cause, because they need nested macro definitions to reproduce and may be uncommon.

@aerooneqq

aerooneqq commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

For the record, example of an expansion data whose syntax context is in the group of same hashes:

ExpnData { kind: Macro(Bang, "from_str_int_impl"), parent: crate0::{{expn0}}, call_site: library/core/src/num/mod.rs:1881:1: 1881:58 (#0), disambiguator: 0, def_site: library/core/src/num/mod.rs:1608:1: 1878:2 (#0), allow_internal_unstable: None, edition: Edition2024, macro_def_id: Some(DefId(0:1352 ~ core[f33e]::num::from_str_int_impl)), parent_module: Some(ModId(DefId(0:305 ~ core[f33e]::num))), allow_internal_unsafe: false, local_inner_macros: false, collapse_debuginfo: false, diagnostic_opaque: false }

This macro:

macro_rules! from_str_int_impl {

Maybe I will be able to make a smaller preproducer and add run make test.

@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (60f2ac3): comparison URL.

Overall result: ❌ regressions - please read:

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.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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.3% [0.1%, 0.9%] 88
Regressions ❌
(secondary)
0.5% [0.1%, 1.1%] 59
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-0.7%, -0.7%] 2
All ❌✅ (primary) 0.3% [0.1%, 0.9%] 88

Max RSS (memory usage)

Results (primary 1.3%, 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)
2.4% [2.2%, 2.8%] 3
Regressions ❌
(secondary)
1.6% [0.6%, 4.3%] 4
Improvements ✅
(primary)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
-0.9% [-0.9%, -0.8%] 2
All ❌✅ (primary) 1.3% [-2.0%, 2.8%] 4

Cycles

Results (primary -1.9%, secondary 1.1%)

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

mean range count
Regressions ❌
(primary)
2.3% [2.2%, 2.3%] 2
Regressions ❌
(secondary)
1.7% [0.5%, 3.0%] 9
Improvements ✅
(primary)
-4.7% [-6.2%, -3.4%] 3
Improvements ✅
(secondary)
-1.7% [-2.8%, -0.7%] 2
All ❌✅ (primary) -1.9% [-6.2%, 2.3%] 5

Binary size

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

Bootstrap: 460.722s -> 459.819s (-0.20%)
Artifact size: 405.70 MiB -> 405.70 MiB (-0.00%)

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

This branch has not been deployed

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

Labels

perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants