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

Optimize query_cache_hit to reduce code size of the query hot path. #107529

Merged
merged 2 commits into from
Feb 8, 2023

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Jan 31, 2023

A small tweak which improves performance on check builds by 0.33% and reduces rustc_driver size by 1%.

BenchmarkBeforeBeforeAfter
TimeTime%Time%
🟣 clap:check1.7978s1.7980s 0.01%1.7930s -0.27%
🟣 hyper:check0.2594s0.2591s -0.12%0.2592s -0.09%
🟣 syntex_syntax:check6.2522s6.2540s 0.03%6.2358s -0.26%
🟣 syn:check1.5889s1.5880s -0.05%1.5799s -0.57%
🟣 regex:check0.9941s0.9939s -0.02%0.9893s -0.49%
Total10.8925s10.8930s 0.01%10.8572s -0.32%
Summary1.0000s0.9997s -0.03%0.9967s -0.33%

r? @cjgillot

@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 Jan 31, 2023
@compiler-errors
Copy link
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 Jan 31, 2023
@bors
Copy link
Contributor

bors commented Jan 31, 2023

⌛ Trying commit 0f85685e521956584bd60923e614d68353f6fe38 with merge f8c1f62c53f582f5eacfa08617ed8e6fb1385ffd...

@@ -393,7 +393,7 @@ impl SelfProfilerRef {
}

/// Record a query in-memory cache hit.
#[inline(always)]
#[inline(never)]
pub fn query_cache_hit(&self, query_invocation_id: QueryInvocationId) {
Copy link
Member

Choose a reason for hiding this comment

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

The same should probably be done for the other profiling events as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem was that it generated code for TimingGuard which was unused. The other events do make use of it so it outlining doesn't help.

@bors
Copy link
Contributor

bors commented Jan 31, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f8c1f62c53f582f5eacfa08617ed8e6fb1385ffd): comparison URL.

Overall result: ❌✅ regressions and improvements - 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)
- - 0
Regressions ❌
(secondary)
0.6% [0.2%, 0.9%] 6
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 2

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)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
-3.7% [-3.7%, -3.7%] 1
Improvements ✅
(secondary)
-2.2% [-4.7%, -1.0%] 7
All ❌✅ (primary) -3.7% [-3.7%, -3.7%] 1

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)
1.7% [1.3%, 2.0%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.7% [1.3%, 2.0%] 3

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 31, 2023
@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 1, 2023

It makes sense that perf regresses since it runs with the profiler enabled. I've optimized query_cache_hit instead to avoid the extra function call and branch in the query system when profiling.

@Zoxc Zoxc changed the title Don't inline query_cache_hit to reduce code size of the query hot path. Optimize query_cache_hit to reduce code size of the query hot path. Feb 1, 2023
@bors
Copy link
Contributor

bors commented Feb 6, 2023

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

@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 6, 2023

It looks like this is a bigger win after #107667:

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check1.8384s1.8200s💚 -1.00%
🟣 hyper:check0.2624s0.2604s -0.74%
🟣 regex:check1.0245s1.0113s💚 -1.28%
🟣 syn:check1.6461s1.6298s -0.99%
🟣 syntex_syntax:check6.3677s6.3036s💚 -1.01%
Total11.1390s11.0252s💚 -1.02%
Summary1.0000s0.9900s💚 -1.00%

@cjgillot
Copy link
Contributor

cjgillot commented Feb 7, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Feb 7, 2023

📌 Commit 9539737 has been approved by cjgillot

It is now in the queue for this repository.

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

bors commented Feb 8, 2023

⌛ Testing commit 9539737 with merge a00e24d...

@bors
Copy link
Contributor

bors commented Feb 8, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Feb 8, 2023

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

@bors bors added merged-by-bors This PR was explicitly merged by bors. labels Feb 8, 2023
@bors bors merged commit a00e24d into rust-lang:master Feb 8, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 8, 2023
@Zoxc Zoxc deleted the inline-tweak-profile branch February 8, 2023 13:48
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a00e24d): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.4%, 0.5%] 5

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

Cycles

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

@rylev
Copy link
Member

rylev commented Feb 14, 2023

Calling this triaged as the regression is small

@rustbot label: perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Feb 14, 2023
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. perf-regression Performance regression. 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.

8 participants