Skip to content

Fix non-deterministic encoding of syntax contexts - #161450

Open
aerooneqq wants to merge 2 commits into
rust-lang:mainfrom
aerooneqq:syntax-ctxt-non-deterministic-encoding
Open

Fix non-deterministic encoding of syntax contexts#161450
aerooneqq wants to merge 2 commits into
rust-lang:mainfrom
aerooneqq:syntax-ctxt-non-deterministic-encoding

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

View all comments

Reiteration of #157409. Explanation can be found in comment for encoding_indices and in the issue.

Fixes #129094. Blocked by #161353.

r? @petrochenkov

No llms used.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 21, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 21, 2026
@rust-log-analyzer

This comment has been minimized.

@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from b07d315 to 3f750ec Compare August 21, 2026 10:33
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from a34d24f to 3868148 Compare September 2, 2026 08:27
@rustbot

This comment has been minimized.

Comment thread compiler/rustc_span/src/hygiene.rs Outdated
.collect()
});

all_ctxt_data.sort_by_key(|&(ctxt, _)| self.get_encoding_index(ctxt));

@petrochenkov petrochenkov Sep 3, 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.

Note: here and below get_encoding_index takes the encoding_indices in every iteration of the loop, it could be more efficient to take the lock once.

View changes since the review

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.

I think we do not need locks at all, I replaced them with RefCells for now, can try to rewrite it without it.

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

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 3, 2026
…ing, r=<try>

Fix non-deterministic encoding of syntax contexts
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 3, 2026
@rust-bors

rust-bors Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 7e01adf (7e01adfdd3209974b2d32d2eb35d4173deaa540b)
Base parent: 4fcf397 (4fcf39725a9c99bd495d8c73af83628a256ff9a9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7e01adf): 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.6% [0.1%, 1.9%] 72
Regressions ❌
(secondary)
0.6% [0.1%, 1.7%] 50
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [0.1%, 1.9%] 72

Max RSS (memory usage)

Results (primary 1.0%, 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)
1.0% [1.0%, 1.0%] 1
Regressions ❌
(secondary)
3.7% [2.6%, 4.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.7% [-4.6%, -1.4%] 5
All ❌✅ (primary) 1.0% [1.0%, 1.0%] 1

Cycles

Results (primary -0.2%, secondary 4.5%)

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)
4.5% [4.5%, 4.5%] 1
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-2.7%, 2.3%] 2

Binary size

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

Bootstrap: 476.065s -> 474.462s (-0.34%)
Artifact size: 401.18 MiB -> 401.32 MiB (0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 3, 2026
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 3, 2026
@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from 3868148 to 4846400 Compare September 7, 2026 09:48
@rustbot rustbot added the A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) label Sep 7, 2026
@rustbot

rustbot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors delegate=aerooneqq try

@rust-bors

rust-bors Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

✌️ @aerooneqq, you can now perform try builds on this pull request!

You can now post @bors try to start a try build.

@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 Sep 7, 2026
…ing, r=<try>

Fix non-deterministic encoding of syntax contexts
@petrochenkov

Copy link
Copy Markdown
Contributor

@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 Sep 7, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors delegate=aerooneqq rustc-timer

@rust-bors

rust-bors Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Unknown argument "rustc-timer". Did you mean to use @bors tryorreview``? Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@rust-bors

rust-bors Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ea02f1d (ea02f1d3fee6db67e8e31ee4fedbf8d1990476ed)
Base parent: 32d94cc (32d94cc9be3f6e6c3fa1deaea9e0ab93c4980dba)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ea02f1d): 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.2% [0.2%, 0.3%] 7
Regressions ❌
(secondary)
0.2% [0.2%, 0.3%] 4
Improvements ✅
(primary)
-0.3% [-0.5%, -0.2%] 5
Improvements ✅
(secondary)
-0.5% [-0.8%, -0.4%] 8
All ❌✅ (primary) -0.0% [-0.5%, 0.3%] 12

Max RSS (memory usage)

Results (primary -2.7%, secondary -2.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)
5.0% [5.0%, 5.0%] 1
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
-4.1% [-4.5%, -3.2%] 4
All ❌✅ (primary) -2.7% [-2.7%, -2.7%] 1

Cycles

Results (secondary -2.6%)

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

Binary size

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

Bootstrap: 477.995s -> 478.812s (0.17%)
Artifact size: 403.44 MiB -> 403.52 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-run-make Area: port run-make Makefiles to rmake.rs 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.

derives: parallel compiler makes builds irreproducible

5 participants