Skip to content

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

Open
aerooneqq wants to merge 11 commits into
rust-lang:mainfrom
aerooneqq:syntax-contexts-and-expansions-ids-remapping
Open

aerooneqq wants to merge 11 commits 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

This comment was marked as outdated.

@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
@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1e274b8): 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.2% [0.1%, 0.3%] 2
Improvements ✅
(primary)
-0.2% [-0.4%, -0.1%] 32
Improvements ✅
(secondary)
-0.4% [-0.8%, -0.1%] 14
All ❌✅ (primary) -0.2% [-0.4%, -0.1%] 32

Max RSS (memory usage)

Results (secondary 1.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)
6.1% [2.6%, 9.9%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.6% [-4.8%, -4.5%] 2
All ❌✅ (primary) - - 0

Cycles

Results (primary 0.8%, secondary 1.6%)

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

mean range count
Regressions ❌
(primary)
5.1% [5.1%, 5.1%] 1
Regressions ❌
(secondary)
3.9% [2.3%, 5.5%] 2
Improvements ✅
(primary)
-3.5% [-3.5%, -3.5%] 1
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) 0.8% [-3.5%, 5.1%] 2

Binary size

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

Bootstrap: 490.893s -> 487.782s (-0.63%)
Artifact size: 406.79 MiB -> 406.98 MiB (0.05%)

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

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 15, 2026
let idx = self.hygiene_ctxt.borrow_mut().get_syntax_ctxt_encoding_index(syntax_context);
idx.encode(self);
self.hygiene_ctxt.borrow_mut().enqueue_syntax_context_for_encoding(syntax_context);
self.emit_u32(self.syntax_context_remapping.map_id(syntax_context).into());

@petrochenkov petrochenkov Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.emit_u32(self.syntax_context_remapping.map_id(syntax_context).into());
self.emit_u32(self.syntax_context_remapping.map_id(syntax_context).as_u32());

It's usually better not to use into outside of generic contexts.
(Same in a few other places.)

View changes since the review

@aerooneqq aerooneqq Oct 15, 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.

Turns out SyntaxContext has (almost) all methods of rustc_index::newtype_index! but it is not an rustc_index::newtype_index!, maybe we should rework it through rustc_index::newtype_index!?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Turns out SyntaxContext has (almost) all methods of rustc_index::newtype_index! but it is not an rustc_index::newtype_index!, maybe we should rework it through rustc_index::newtype_index!?

Yes, it would be good to try (not in this PR), maybe it was just missed when similar newtypes were migrated to newtype_index!.

Comment thread compiler/rustc_metadata/src/rmeta/encoder.rs Outdated
Comment thread compiler/rustc_metadata/src/rmeta/encoder.rs Outdated
Comment thread compiler/rustc_metadata/src/rmeta/encoder.rs Outdated
Comment thread compiler/rustc_middle/src/query/on_disk_cache.rs Outdated
Comment thread compiler/rustc_span/src/hygiene.rs Outdated
Comment thread compiler/rustc_span/src/hygiene.rs Outdated
Comment thread compiler/rustc_span/src/hygiene.rs Outdated
Comment thread compiler/rustc_span/src/hygiene.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

Some style nits and one remaining bigger problem (#163668 (comment)).
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 15, 2026
@rustbot

rustbot commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@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 15, 2026
@rust-bors

This comment has been minimized.

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

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

rust-bors Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 16bad69 (16bad6970e588aaf1a6a1209c1dbc71db8f90238)
Base parent: 8a9dd7a (8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (16bad69): 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.2% [0.1%, 0.4%] 3
Improvements ✅
(primary)
-0.3% [-0.8%, -0.1%] 50
Improvements ✅
(secondary)
-0.4% [-0.9%, -0.1%] 24
All ❌✅ (primary) -0.3% [-0.8%, -0.1%] 50

Max RSS (memory usage)

Results (primary 0.4%, secondary 2.5%)

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

mean range count
Regressions ❌
(primary)
1.7% [0.5%, 2.4%] 5
Regressions ❌
(secondary)
3.6% [2.1%, 5.3%] 11
Improvements ✅
(primary)
-3.0% [-4.9%, -1.0%] 2
Improvements ✅
(secondary)
-3.6% [-4.9%, -2.2%] 2
All ❌✅ (primary) 0.4% [-4.9%, 2.4%] 7

Cycles

Results (primary 2.5%, secondary -3.4%)

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)
3.3% [3.3%, 3.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.1% [-12.0%, -2.1%] 4
All ❌✅ (primary) 2.5% [2.5%, 2.5%] 1

Binary size

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

Bootstrap: 490.736s -> 490.318s (-0.09%)
Artifact size: 407.05 MiB -> 407.18 MiB (0.03%)

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

Copy link
Copy Markdown
Contributor Author

@rustbot ready
Perf is ok, but code is a bit ugly.

@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 15, 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-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