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

Split execute_job into execute_job_incr and execute_job_non_incr #109046

Merged
merged 2 commits into from
Mar 21, 2023

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 12, 2023

execute_job was a bit large, so this splits it in 2. Performance was neutral locally, but this may affect bootstrap times.

@rustbot
Copy link
Collaborator

rustbot commented Mar 12, 2023

r? @michaelwoerister

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

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Mar 12, 2023
}
let prof_timer = qcx.dep_context().profiler().query_provider();
let result = qcx.start_query(job_id, query.depth_limit(), None, || query.compute(qcx, key));
let dep_node_index = qcx.dep_context().dep_graph().next_virtual_depnode_index();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you encapsulate next_virtual_depnode_index? The goal is to make sure that it is only called when DepGraph::data is None.

For instance, making DepGraph::Data return some marker type DisabledDepGraph on which we can call that method?

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 tried to make a marker type struct DisabledDepGraph<'a, K: DepKind>(&'a DepGraph<K>), but it doesn't seem like LLVM was able to optimize it away:

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check1.7102s1.7175s 0.43%
🟣 hyper:check0.2533s0.2538s 0.23%
🟣 regex:check0.9534s0.9567s 0.35%
🟣 syn:check1.5869s1.5971s 0.64%
🟣 syntex_syntax:check6.1097s6.1317s 0.36%
Total10.6134s10.6568s 0.41%
Summary1.0000s1.0040s 0.40%

Copy link
Contributor

Choose a reason for hiding this comment

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

What about DisabledDepGraph(Lrc<AtomicU32>), and have the dep-graph hand out references to that struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds very performance equivalent.

Copy link
Member

Choose a reason for hiding this comment

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

How about adding assert!(self.data.is_none()); to DepGraph::next_virtual_depnode_index()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems to be cheaper:

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check1.7151s1.7189s 0.22%
🟣 hyper:check0.2516s0.2525s 0.34%
🟣 regex:check0.9532s0.9538s 0.06%
🟣 syn:check1.5406s1.5400s -0.04%
🟣 syntex_syntax:check5.9116s5.9193s 0.13%
Total10.3722s10.3845s 0.12%
Summary1.0000s1.0014s 0.14%

There's a 0.01% code size increase so it probably doesn't get optimized away.

@cjgillot cjgillot self-assigned this Mar 12, 2023
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 12, 2023

Could I get a perf run? I want to see if this affects bootstrap times before growing the PR larger.

@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 Mar 12, 2023
@bors
Copy link
Contributor

bors commented Mar 12, 2023

⌛ Trying commit 5bdc711b0c18afd0867e296085eafd4437bfcb9c with merge 8202e830070034d6387c18efbcdec4084be63938...

@bors
Copy link
Contributor

bors commented Mar 12, 2023

☀️ Try build successful - checks-actions
Build commit: 8202e830070034d6387c18efbcdec4084be63938 (8202e830070034d6387c18efbcdec4084be63938)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8202e830070034d6387c18efbcdec4084be63938): comparison URL.

Overall result: ✅ improvements - 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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.6%, -0.3%] 2
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)
- - 0
Regressions ❌
(secondary)
3.8% [2.5%, 6.0%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.3% [-4.3%, -4.3%] 1
All ❌✅ (primary) - - 0

Cycles

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 12, 2023
@michaelwoerister
Copy link
Member

The changes look good to me.
r? @cjgillot (in case you'd like to further discuss #109046 (comment))

@rustbot
Copy link
Collaborator

rustbot commented Mar 15, 2023

Could not assign reviewer from: cjgillot.
User(s) cjgillot are either the PR author or are already assigned, and there are no other candidates.
Use r? to specify someone else to assign.

@cjgillot
Copy link
Contributor

r=me with the assertion #109046 (comment) added.

@cjgillot cjgillot 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 Mar 18, 2023
@michaelwoerister
Copy link
Member

@bors r=cjgillot,michaelwoerister

@bors
Copy link
Contributor

bors commented Mar 20, 2023

📌 Commit c4bcac6 has been approved by cjgillot,michaelwoerister

It is now in the queue for this repository.

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

bors commented Mar 20, 2023

⌛ Testing commit c4bcac6 with merge 822c10f...

@bors
Copy link
Contributor

bors commented Mar 21, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot,michaelwoerister
Pushing 822c10f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 21, 2023
@bors bors merged commit 822c10f into rust-lang:master Mar 21, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 21, 2023
@Zoxc Zoxc deleted the split-execute-job branch March 21, 2023 02:28
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (822c10f): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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)
- - 0
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 1

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)
2.1% [0.6%, 3.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-3.5%, -0.7%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-3.5%, 3.5%] 6

Cycles

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

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 25, 2023
Refactor `try_execute_query`

This merges `JobOwner::try_start` into `try_execute_query`, removing `TryGetJob` in the processes. 3 new functions are extracted from `try_execute_query`: `execute_job`, `cycle_error` and `wait_for_query`. This makes the control flow a bit clearer and improves performance.

Based on rust-lang#109046.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7134s</td><td align="right">1.7061s</td><td align="right"> -0.43%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2519s</td><td align="right">0.2510s</td><td align="right"> -0.35%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9517s</td><td align="right">0.9481s</td><td align="right"> -0.38%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5389s</td><td align="right">1.5338s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.9488s</td><td align="right">5.9258s</td><td align="right"> -0.39%</td></tr><tr><td>Total</td><td align="right">10.4048s</td><td align="right">10.3647s</td><td align="right"> -0.38%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9962s</td><td align="right"> -0.38%</td></tr></table>

r? `@cjgillot`
oli-obk pushed a commit to oli-obk/miri that referenced this pull request Apr 4, 2023
Refactor `try_execute_query`

This merges `JobOwner::try_start` into `try_execute_query`, removing `TryGetJob` in the processes. 3 new functions are extracted from `try_execute_query`: `execute_job`, `cycle_error` and `wait_for_query`. This makes the control flow a bit clearer and improves performance.

Based on rust-lang/rust#109046.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7134s</td><td align="right">1.7061s</td><td align="right"> -0.43%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2519s</td><td align="right">0.2510s</td><td align="right"> -0.35%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9517s</td><td align="right">0.9481s</td><td align="right"> -0.38%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5389s</td><td align="right">1.5338s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.9488s</td><td align="right">5.9258s</td><td align="right"> -0.39%</td></tr><tr><td>Total</td><td align="right">10.4048s</td><td align="right">10.3647s</td><td align="right"> -0.38%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9962s</td><td align="right"> -0.38%</td></tr></table>

r? `@cjgillot`
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) merged-by-bors This PR was explicitly merged by bors. 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.

6 participants