Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase parallelism in various locations #115003

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Aug 19, 2023

This is a rebase of #67870 which consists of various additions of parallelism in the compiler.

Performance improvement for the parallel compiler with 6 threads:

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check0.7382s0.6639s💚 -10.07%
🟣 hyper:check0.1873s0.1609s💚 -14.10%
🟣 regex:check0.4478s0.4173s💚 -6.81%
🟣 syn:check0.7475s0.6857s💚 -8.26%
🟣 syntex_syntax:check2.3616s2.1652s💚 -8.32%
Total4.4823s4.0929s💚 -8.69%
Summary1.0000s0.9049s💚 -9.51%

cc @SparrowLii

@rustbot
Copy link
Collaborator

rustbot commented Aug 19, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added 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 Aug 19, 2023
@cjgillot cjgillot self-assigned this Aug 20, 2023
compiler/rustc_hir_analysis/src/lib.rs Outdated Show resolved Hide resolved
@@ -757,14 +757,28 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
CStore::from_tcx(tcx).report_unused_deps(tcx);
},
{
// Prefetch this as it is used later by the loop below
// to prevent multiple threads from blocking on it.
let _ = tcx.get_lang_items(());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be fixed in query infra, yielding control to another job if blocked on another query?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somewhat by using a thread pool with fibers. That's not a short term fix and it's not free, so we might want to keep these anyway.

compiler/rustc_hir_analysis/src/collect.rs Show resolved Hide resolved
// FIXME: Remove this when we implement creating `DefId`s
// for anon constants during their parents' typeck.
// Typeck all body owners in parallel will produce queries
// cycle errors because it may typeck on anon constants directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the cycle issue fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR just moves this code. It shouldn't have any effect on any cycle issue.

@@ -805,7 +805,8 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
sess.time("misc_checking_2", || {
parallel!(
{
tcx.ensure().effective_visibilities(());
// Prefetch this as it is used later by lint checking and privacy checking.
let _ = tcx.effective_visibilities(());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't the ensure enough? effective_visibilities is eval_always.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed all the prefetching to use ensure_with_value. It's nicer than having to rely on queries being eval_always which might possibly change.

self.reference.bget(index).map(&self.closure)
//~^ ERROR unconstrained generic constant
//~| ERROR mismatched types
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do the additional diags come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compilation no long immediately stops on fatal errors and instead wait for all parallel executions to be complete. The serial compiler simulates this behavior to ensure test outputs match.

compiler/rustc_interface/src/passes.rs Outdated Show resolved Hide resolved
compiler/rustc_interface/src/passes.rs Outdated Show resolved Hide resolved
@cjgillot
Copy link
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 Aug 20, 2023
@bors
Copy link
Contributor

bors commented Aug 20, 2023

⌛ Trying commit f9d12e2a6022cbbed60f458a78502791ec77ccef with merge 5f30bb0cbc3842d6520bacf4d7dea860e138c4d9...

@bors
Copy link
Contributor

bors commented Aug 20, 2023

☀️ Try build successful - checks-actions
Build commit: 5f30bb0cbc3842d6520bacf4d7dea860e138c4d9 (5f30bb0cbc3842d6520bacf4d7dea860e138c4d9)

@rust-timer

This comment has been minimized.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from f9d12e2 to 1821289 Compare August 20, 2023 12:26
@rust-log-analyzer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5f30bb0cbc3842d6520bacf4d7dea860e138c4d9): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
4.2% [0.4%, 87.3%] 126
Regressions ❌
(secondary)
11.6% [0.2%, 77.0%] 166
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.2% [0.4%, 87.3%] 126

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.8% [0.6%, 19.5%] 117
Regressions ❌
(secondary)
8.1% [1.3%, 23.5%] 196
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.3% [-1.3%, -1.3%] 1
All ❌✅ (primary) 3.8% [0.6%, 19.5%] 117

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
6.5% [1.2%, 68.7%] 65
Regressions ❌
(secondary)
14.6% [1.9%, 61.4%] 115
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 6.5% [1.2%, 68.7%] 65

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 2
Regressions ❌
(secondary)
0.1% [0.0%, 0.3%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 2

Bootstrap: 636.001s -> 635.653s (-0.05%)
Artifact size: 346.92 MiB -> 347.11 MiB (0.06%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 20, 2023
@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from 1821289 to d125a5d Compare August 20, 2023 13:13
@Zoxc
Copy link
Contributor Author

Zoxc commented Aug 20, 2023

I avoided prefetching of visible_parent_map as that wasn't always executed. This could use another perf run now.

@lqd
Copy link
Member

lqd commented Aug 20, 2023

@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 Aug 20, 2023
@bors
Copy link
Contributor

bors commented Aug 20, 2023

⌛ Trying commit d125a5d8c1dc23342aa5641675df34d33a76958f with merge 78a3877375fe23c25e4c0ea3ff01b84d806cd35d...

@bors
Copy link
Contributor

bors commented Aug 20, 2023

☀️ Try build successful - checks-actions
Build commit: 78a3877375fe23c25e4c0ea3ff01b84d806cd35d (78a3877375fe23c25e4c0ea3ff01b84d806cd35d)

@rust-timer

This comment has been minimized.

@compiler-errors compiler-errors removed their assignment Aug 20, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (78a3877375fe23c25e4c0ea3ff01b84d806cd35d): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.7% [0.8%, 3.1%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
3.2% [2.5%, 3.9%] 2
Improvements ✅
(primary)
-3.7% [-3.7%, -3.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.3% [-3.7%, 1.1%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 2
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.1% [-1.1%, -1.1%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 636.195s -> 635.468s (-0.11%)
Artifact size: 346.98 MiB -> 347.12 MiB (0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 20, 2023
@bors
Copy link
Contributor

bors commented Aug 27, 2023

☔ The latest upstream changes (presumably #115226) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from adf2a24 to a84acd2 Compare August 27, 2023 19:55
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from a84acd2 to 8c94f1f Compare August 27, 2023 20:50
@bors
Copy link
Contributor

bors commented Aug 30, 2023

☔ The latest upstream changes (presumably #115144) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from 8c94f1f to 7d9bf5a Compare August 30, 2023 23:04
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from 7d9bf5a to 946b97d Compare August 31, 2023 01:06
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from 946b97d to 8747443 Compare August 31, 2023 02:06
@bors
Copy link
Contributor

bors commented Sep 6, 2023

☔ The latest upstream changes (presumably #115401) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from 8747443 to dc4688b Compare September 8, 2023 16:22
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from dc4688b to e26db41 Compare September 22, 2023 20:36
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from e26db41 to a07cb22 Compare September 22, 2023 22:20
@onur-ozkan onur-ozkan removed the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Oct 13, 2023
@bors
Copy link
Contributor

bors commented Oct 25, 2023

☔ The latest upstream changes (presumably #116482) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from a07cb22 to ec1df88 Compare January 19, 2024 08:18
@bors
Copy link
Contributor

bors commented Jan 19, 2024

☔ The latest upstream changes (presumably #120112) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the parallel-tweaks-rebase branch from ec1df88 to 01ae9a3 Compare February 29, 2024 22:24
@bors
Copy link
Contributor

bors commented Mar 7, 2024

☔ The latest upstream changes (presumably #121154) made this pull request unmergeable. Please resolve the merge conflicts.

@oskgo
Copy link
Contributor

oskgo commented Aug 9, 2024

@Zoxc Any updates on this? Thanks

@Zoxc
Copy link
Contributor Author

Zoxc commented Aug 9, 2024

You can probably consider this blocked on rust-lang/rustc-rayon#12.

@oskgo oskgo added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. 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.