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

Refactor query system to maintain a global job id counter #93741

Merged
merged 1 commit into from
Feb 9, 2022

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Feb 7, 2022

This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to Cell<u64> as the backing
storage over a u64, but the latter was already inside a RefCell so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 7, 2022
@rust-highfive
Copy link
Collaborator

r? @oli-obk

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 7, 2022
@Mark-Simulacrum
Copy link
Member Author

@bors try @rust-timer queue

Expecting this to potentially cause some noise just because this code is quite hot, but likely to be largely neutral.

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 7, 2022
@bors
Copy link
Contributor

bors commented Feb 7, 2022

⌛ Trying commit d4a783abdfc9cad833f87532e231523117194764 with merge 5ebf14f5a1b120efc229c7b3b2e2571d82dc7496...

@bors
Copy link
Contributor

bors commented Feb 7, 2022

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

@rust-timer
Copy link
Collaborator

Queued 5ebf14f5a1b120efc229c7b3b2e2571d82dc7496 with parent c5e4148, future comparison URL.

@cjgillot cjgillot self-assigned this Feb 7, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5ebf14f5a1b120efc229c7b3b2e2571d82dc7496): comparison url.

Summary: This benchmark run shows 3 relevant regressions 😿 to instruction counts.

  • Average relevant regression: 1.2%
  • Largest regression in instruction counts: 1.2% on incr-unchanged builds of ctfe-stress-4 check

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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 led 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-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 7, 2022
@Mark-Simulacrum Mark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Feb 7, 2022
@Mark-Simulacrum
Copy link
Member Author

Similar to #93724 (comment), the regression seems real but is likely optimizer noise we can't really do much about.

@cjgillot
Copy link
Contributor

cjgillot commented Feb 8, 2022

For the moment, the parallel compiler efforts have pretty much stalled.
This is a great simplification, which should not irreversibly break the parallel compiler.
@bors r+

@bors
Copy link
Contributor

bors commented Feb 8, 2022

📌 Commit d4a783abdfc9cad833f87532e231523117194764 has been approved by cjgillot

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 8, 2022
@Mark-Simulacrum
Copy link
Member Author

@bors r-

I was thinking about this and realized we should keep the checked_add to ensure uniqueness, so will just amend this and r=you with that most likely.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 8, 2022
This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to `Cell<u64>` as the backing
storage over a `u64`, but the latter was already inside a `RefCell` so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.
@Mark-Simulacrum
Copy link
Member Author

@bors r=cjgillot

Replaced the u32 with a u64 -- even simpler, and avoids complicated increments to the atomic in a parallel context.

@bors
Copy link
Contributor

bors commented Feb 8, 2022

📌 Commit e240783 has been approved by cjgillot

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 8, 2022
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 8, 2022
@bors
Copy link
Contributor

bors commented Feb 9, 2022

⌛ Testing commit e240783 with merge e7aca89...

@bors
Copy link
Contributor

bors commented Feb 9, 2022

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing e7aca89 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 9, 2022
@bors bors merged commit e7aca89 into rust-lang:master Feb 9, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 9, 2022
@Mark-Simulacrum Mark-Simulacrum deleted the global-job-id branch February 9, 2022 21:54
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e7aca89): comparison url.

Summary: This benchmark run did not return any relevant results. 28 results were found to be statistically significant but too small to be relevant.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

@rustbot rustbot removed the perf-regression Performance regression. label Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants