Skip to content

Remap syntax contexts and expansion ids for det. metadata encoding - #163668

Draft
aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:syntax-contexts-and-expansions-ids-remapping
Draft

aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:syntax-contexts-and-expansions-ids-remapping

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

#163495 which parallelizes AST -> HIR lowering breaks det. encoding of syntax contexts and expansions, however this PR with #162809 should fix the problem.

Now draft for perf and CI (dont look at the code). Remapping of those entities can cost us much, because unlike def ids there may be many expansions and contexts after we committed end of determinism.

r? @petrochenkov

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 2, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 2, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@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 Oct 2, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 2, 2026
…remapping, r=<try>

Remap syntax contexts and expansion ids for det. metadata encoding
@rust-bors

This comment has been minimized.

@aerooneqq
aerooneqq force-pushed the syntax-contexts-and-expansions-ids-remapping branch from 4195a79 to 46ee492 Compare October 2, 2026 15:57
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try cancel

@rust-bors

rust-bors Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Try build cancelled. Cancelled workflows:

Hint: if you want to run another try build, you do not need to manually cancel the previous one. Just run @bors try and bors will cancel the previous build automatically.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 2, 2026
…remapping, r=<try>

Remap syntax contexts and expansion ids for det. metadata encoding
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 19b2816 failed: CI. Failed jobs:

@aerooneqq
aerooneqq force-pushed the syntax-contexts-and-expansions-ids-remapping branch 2 times, most recently from 07a0f64 to 43e622c Compare October 5, 2026 14:34
@aerooneqq

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
…remapping, r=<try>

Remap syntax contexts and expansion ids for det. metadata encoding
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a7c6732 (a7c67326654d086b506b6f55d82af110f520b88b)
Base parent: 602727f (602727f26878dcf9eb2999e2f58e5df1269ff47e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (a7c6732): 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.7% [0.3%, 1.2%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-1.2%, -0.1%] 57
Improvements ✅
(secondary)
-0.3% [-0.7%, -0.1%] 28
All ❌✅ (primary) -0.1% [-1.2%, 1.2%] 64

Max RSS (memory usage)

Results (primary -2.9%, secondary -1.7%)

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

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
2.6% [1.6%, 6.6%] 9
Improvements ✅
(primary)
-3.0% [-8.3%, -0.9%] 112
Improvements ✅
(secondary)
-3.1% [-5.4%, -1.2%] 29
All ❌✅ (primary) -2.9% [-8.3%, 3.1%] 113

Cycles

Results (primary 11.8%, secondary 2.4%)

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

mean range count
Regressions ❌
(primary)
11.8% [2.3%, 27.3%] 15
Regressions ❌
(secondary)
3.8% [3.0%, 4.5%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.4% [-4.4%, -4.4%] 1
All ❌✅ (primary) 11.8% [2.3%, 27.3%] 15

Binary size

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

Bootstrap: 490.152s -> 495.841s (1.16%)
Artifact size: 408.63 MiB -> 408.61 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 5, 2026
@aerooneqq
aerooneqq force-pushed the syntax-contexts-and-expansions-ids-remapping branch 2 times, most recently from aff6a28 to 34a75c8 Compare October 6, 2026 13:00
@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 Oct 6, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
…remapping, r=<try>

Remap syntax contexts and expansion ids for det. metadata encoding
@rust-bors

rust-bors Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 7bc5025 (7bc50256f104e1317a31182442df8ccc6f17b131)
Base parent: b57eb9a (b57eb9a5fd94f30697f51fc88fbe898e67c7aae6)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7bc5025): 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
Regressions ❌
(secondary)
0.5% [0.3%, 0.6%] 2
Improvements ✅
(primary)
-0.2% [-0.4%, -0.2%] 32
Improvements ✅
(secondary)
-0.3% [-0.7%, -0.1%] 28
All ❌✅ (primary) -0.2% [-0.4%, -0.2%] 32

Max RSS (memory usage)

Results (primary -1.1%, secondary -1.3%)

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)
3.3% [2.7%, 3.8%] 3
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-3.3% [-5.4%, -0.9%] 7
All ❌✅ (primary) -1.1% [-1.1%, -1.1%] 1

Cycles

Results (primary 2.3%, secondary -6.4%)

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.3%, 2.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.4% [-14.6%, -3.8%] 8
All ❌✅ (primary) 2.3% [2.3%, 2.3%] 1

Binary size

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

Bootstrap: 489.693s -> 489.628s (-0.01%)
Artifact size: 409.33 MiB -> 408.61 MiB (-0.18%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 6, 2026
@aerooneqq
aerooneqq force-pushed the syntax-contexts-and-expansions-ids-remapping branch from 34a75c8 to 0d8a6c0 Compare October 6, 2026 16:02
@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 Oct 7, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…remapping, r=<try>

Remap syntax contexts and expansion ids for det. metadata encoding
@rust-bors

rust-bors Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 37acb80 (37acb80f7852dea4ca8afa0f9791fd8019455cfa)
Base parent: 8d1a764 (8d1a76430406c877b35d0b627e7f796dcf0dfeca)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (37acb80): 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.2% [-0.4%, -0.1%] 28
Improvements ✅
(secondary)
-0.3% [-0.7%, -0.1%] 23
All ❌✅ (primary) -0.2% [-0.4%, -0.1%] 28

Max RSS (memory usage)

Results (primary -0.6%, secondary -1.0%)

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

mean range count
Regressions ❌
(primary)
1.7% [1.1%, 2.2%] 2
Regressions ❌
(secondary)
3.4% [2.9%, 3.8%] 2
Improvements ✅
(primary)
-2.8% [-4.4%, -1.2%] 2
Improvements ✅
(secondary)
-5.3% [-5.3%, -5.3%] 2
All ❌✅ (primary) -0.6% [-4.4%, 2.2%] 4

Cycles

Results (secondary 0.8%)

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)
3.3% [3.2%, 3.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.2% [-4.2%, -4.2%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 489.893s -> 490.336s (0.09%)
Artifact size: 408.60 MiB -> 408.69 MiB (0.02%)

@rustbot rustbot removed perf-regression Performance regression. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 7, 2026
}
}

pub struct SyntaxContextRemapper<'a>(&'a mut HygieneData);

@aerooneqq aerooneqq Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done for the following reasons:

  • HygieneData is private and as I understood it should not be exposed outside of the crate
  • There are a lot of common things in remapping of syntax contexts and local expansion ids, they differ only in small details like hash calculation, those common things are placed in default functions of HygieneEntityRemapper trait
  • Those structs contain static functions to access remappers for syntax contexts and local expansion ids, as HygieneData is not accessible
  • Also we take the lock for the whole time of remapping calculation, so we do not acquire lock on every hash operation for example, it is ensured by &'a mut HygieneData (it can be a problem if we do it in parallel, meaning calculation of syntax contexts and local expansion remapping), however that is the problem with design of access to HygieneData as it always takes mutable lock, but after certain stage in compilation it should behave like a FreezeLock, as there should be only readonly accesses

I am not that sure about the design, so If you don't like it I can rework it somehow, but it seems to satisfy the conditions/thoughts above.

@rustbot ready

View changes since the review

@rustbot rustbot 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 Oct 8, 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

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

5 participants