Skip to content

Parallel frontend: reproducible def ids for RPITITs - #162555

Open
susitsm wants to merge 2 commits into
rust-lang:mainfrom
susitsm:parallel-frontend-162202
Open

susitsm wants to merge 2 commits into
rust-lang:mainfrom
susitsm:parallel-frontend-162202

Conversation

@susitsm

@susitsm susitsm commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Adds test and fixes #162202 by making sure that DefId generating queries in typecheck are called serially

r? @petrochenkov

@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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 9, 2026
Comment thread compiler/rustc_hir_analysis/src/check/wfcheck.rs Outdated
@susitsm
susitsm force-pushed the parallel-frontend-162202 branch from 03dcc6f to 2836b86 Compare September 10, 2026 06:46
@petrochenkov petrochenkov changed the title Parallel frontend 162202 Parallel frontend: reproducible def ids for RPITITs Sep 10, 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 Sep 10, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 10, 2026
Parallel frontend: reproducible def ids for RPITITs
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 10, 2026
@rust-bors

rust-bors Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: bccd62b (bccd62bdc7801ec896a024c8948ac384caa22d0b)
Base parent: c4c4a57 (c4c4a576936e9e67717d0deb8e74e02dd5dd10de)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (bccd62b): 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.5% [0.1%, 1.1%] 66
Regressions ❌
(secondary)
0.7% [0.0%, 2.8%] 63
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [0.1%, 1.1%] 66

Max RSS (memory usage)

Results (primary -0.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)
0.7% [0.5%, 1.0%] 2
Regressions ❌
(secondary)
3.4% [3.1%, 3.6%] 2
Improvements ✅
(primary)
-1.6% [-3.3%, -0.5%] 5
Improvements ✅
(secondary)
-4.3% [-4.7%, -4.0%] 4
All ❌✅ (primary) -0.9% [-3.3%, 1.0%] 7

Cycles

Results (primary 0.1%, secondary 5.2%)

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

mean range count
Regressions ❌
(primary)
0.7% [0.4%, 1.6%] 10
Regressions ❌
(secondary)
5.2% [5.2%, 5.2%] 1
Improvements ✅
(primary)
-0.7% [-0.8%, -0.6%] 8
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-0.8%, 1.6%] 18

Binary size

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

Bootstrap: 480.118s -> 480.397s (0.06%)
Artifact size: 403.78 MiB -> 403.73 MiB (-0.01%)

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

pub(super) fn check_type_wf(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> {
assign_anon_assoc_item_def_ids(tcx);
remap_opaque_captures(tcx);

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

These calls can be put under if tcx.sess.opts.jobs.frontend.is_some() to avoid regressing single-threaded performance.

View changes since the review

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.

Do assign_anon_assoc_item_def_ids/remap_opaque_captures create the def ids in the same order as single-threaded check_type_wf?

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.

Not sure, but likely not. The regression seems to come from calling resolve_bound_vars for everything.

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.

Modified remap_opaque_captures to only run resolve_bound_vars on the parents of opaques. It solved the problem locally on the biggest regression, typenum

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.

Not sure, but likely not.

Ideally, changing -j N to -j M should not change the produced binaries (including when N or M is 1).

@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 10, 2026
… in deterministic order regardless of parallelism
@susitsm
susitsm force-pushed the parallel-frontend-162202 branch from 2836b86 to cb6e6d3 Compare September 11, 2026 09:08
@JonathanBrouwer

Copy link
Copy Markdown
Member

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

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 11, 2026
Parallel frontend: reproducible def ids for RPITITs
@rust-bors

rust-bors Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 1fd98d3 (1fd98d3af1ab651fe641e1e2be84af00e279bda3)
Base parent: a59b87a (a59b87ab9929f0361031e0d0080a9bf2ea4cdbc0)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1fd98d3): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

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

Max RSS (memory usage)

Results (primary 1.3%, 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)
1.6% [0.7%, 2.8%] 7
Regressions ❌
(secondary)
3.4% [2.2%, 4.7%] 3
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.3% [-0.4%, 2.8%] 8

Cycles

Results (primary 0.1%)

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

mean range count
Regressions ❌
(primary)
1.0% [0.5%, 1.6%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-1.1%, -0.4%] 9
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-1.1%, 1.6%] 16

Binary size

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

Bootstrap: 479.056s -> 485.246s (1.29%)
Artifact size: 403.79 MiB -> 403.80 MiB (0.00%)

@rustbot rustbot removed perf-regression Performance regression. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 11, 2026
@Zoxc

Zoxc commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Do note that I've not intended DefIds to be deterministic. Another strategy would be to make them deterministic when writing metadata. They should also never appear in code output.

@petrochenkov

Copy link
Copy Markdown
Contributor

Another strategy would be to make them deterministic when writing metadata.

That would be #162809 (see the perf numbers in particular).

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

Labels

A-run-make Area: port run-make Makefiles to rmake.rs 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.

parallel compiler: async fns not reproducible

7 participants