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 incremental_verify_ich #109371

Merged
merged 4 commits into from
Mar 25, 2023
Merged

Optimize incremental_verify_ich #109371

merged 4 commits into from
Mar 25, 2023

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 19, 2023

This optimizes incremental_verify_ich by operating on SerializedDepNodeIndex, saving 2 hashmap lookups. The panic paths are also changed to get a TyCtxt reference using TLS.

@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2023

r? @jackh726

(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 19, 2023
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the verify-hash-opt branch from 1fc40d6 to a6c7b38 Compare March 20, 2023 00:30
@rustbot
Copy link
Collaborator

rustbot commented Mar 20, 2023

These commits modify compiler targets.
(See the Target Tier Policy.)

These commits modify the Cargo.lock file. Random changes to Cargo.lock can be introduced when switching branches and rebasing PRs.
This was probably unintentional and should be reverted before this PR is merged.

If this was intentional then you can ignore this comment.

@Zoxc Zoxc force-pushed the verify-hash-opt branch from a6c7b38 to a00cf92 Compare March 20, 2023 00:31
@Noratrieb
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 Mar 20, 2023
@bors
Copy link
Contributor

bors commented Mar 20, 2023

⌛ Trying commit a00cf9280d48328a9f31c1f212d4f843b05ff5c4 with merge 057c6329ca8ff62e8e5c6a26d5fd1d6b7b6fbc12...

@bors
Copy link
Contributor

bors commented Mar 20, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (057c6329ca8ff62e8e5c6a26d5fd1d6b7b6fbc12): 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.8% [-1.5%, -0.4%] 70
Improvements ✅
(secondary)
-1.4% [-2.2%, -0.6%] 21
All ❌✅ (primary) -0.8% [-1.5%, -0.4%] 70

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.8% [0.5%, 1.0%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.8%, -0.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.8%, 1.0%] 4

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)
3.8% [3.0%, 4.6%] 2
Improvements ✅
(primary)
-0.6% [-1.1%, -0.4%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-1.1%, -0.4%] 6

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 20, 2023
@Zoxc Zoxc force-pushed the verify-hash-opt branch from a00cf92 to 2e7c50f Compare March 20, 2023 15:45
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 20, 2023

Let's do a perf run with DebugArg removed too, to see if anything interesting shows up.

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

bors commented Mar 20, 2023

⌛ Trying commit 2e7c50f62afbdf4fea28ea789d5d1a2d8ddee77f with merge 64c144e1a80f93ec678f258c8569a703deef71ad...

@cjgillot cjgillot self-assigned this Mar 20, 2023
@bors
Copy link
Contributor

bors commented Mar 20, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Mar 20, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (64c144e1a80f93ec678f258c8569a703deef71ad): 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.8% [-1.5%, -0.3%] 75
Improvements ✅
(secondary)
-1.3% [-2.0%, -0.5%] 25
All ❌✅ (primary) -0.8% [-1.5%, -0.3%] 75

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.7% [0.4%, 1.0%] 2
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
-1.9% [-3.8%, -0.4%] 6
Improvements ✅
(secondary)
-2.9% [-4.4%, -1.4%] 52
All ❌✅ (primary) -1.3% [-3.8%, 1.0%] 8

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)
- - 0
Improvements ✅
(primary)
-0.6% [-0.7%, -0.5%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.7%, -0.5%] 3

pub fn is_green(&self, dep_node: &DepNode<K>) -> bool {
self.node_color(dep_node).map_or(false, |c| c.is_green())
#[inline]
pub fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool {
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 still be called is_green, or is there a conflict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can. I just renamed it to contrast with the other is_green method.

let _current_fingerprint =
crate::query::incremental_verify_ich(cx, data, result, &node, hash_result);
if let Some(prev_index) = data.previous.node_to_index_opt(&node)
&& let Some(dep_node_index) = { data.current.prev_index_to_index.lock()[prev_index] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
&& let Some(dep_node_index) = { data.current.prev_index_to_index.lock()[prev_index] }
// Wrap the call to `lock()` in braces to unlock it before proceeding.
&& let Some(dep_node_index) = { data.current.prev_index_to_index.lock()[prev_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.

You can't use braces like that to shorted lifetimes. I changed it to use nested ifs instead.

},
}
}
Tcx::with_context(|tcx| {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just pass tcx as an argument to incremental_verify_ich_not_green?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I avoided passing it so it wouldn't affect the hot path. It's a quite minor improvement though.

#[cold]
fn incremental_verify_ich_failed(sess: &Session, dep_node: DebugArg<'_>, result: DebugArg<'_>) {
#[inline(never)]
fn incremental_verify_ich_failed<Tcx>(prev_index: SerializedDepNodeIndex, result: &dyn Debug)
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise, can we pass tcx here?

@Zoxc Zoxc force-pushed the verify-hash-opt branch from 2e7c50f to 820e3a8 Compare March 25, 2023 02:16
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 25, 2023

I changed it to pass tcx directly. We should do another perf run to verify that it doesn't regress anything.

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

bors commented Mar 25, 2023

⌛ Trying commit 820e3a8 with merge 223ac5351eb2e7ef0fc641afb06ec00d6fae10b5...

@bors
Copy link
Contributor

bors commented Mar 25, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (223ac5351eb2e7ef0fc641afb06ec00d6fae10b5): 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.9% [-1.5%, -0.4%] 69
Improvements ✅
(secondary)
-1.1% [-2.1%, -0.4%] 33
All ❌✅ (primary) -0.9% [-1.5%, -0.4%] 69

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)
1.1% [0.5%, 1.9%] 5
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
-0.9% [-1.8%, -0.5%] 6
All ❌✅ (primary) -0.8% [-2.6%, 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)
1.7% [1.5%, 2.0%] 3
Regressions ❌
(secondary)
0.9% [0.6%, 1.5%] 11
Improvements ✅
(primary)
-1.7% [-2.1%, -1.1%] 6
Improvements ✅
(secondary)
-1.2% [-2.0%, -0.4%] 2
All ❌✅ (primary) -0.6% [-2.1%, 2.0%] 9

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

@bors r+

@bors
Copy link
Contributor

bors commented Mar 25, 2023

📌 Commit 820e3a8 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 Mar 25, 2023
@bors
Copy link
Contributor

bors commented Mar 25, 2023

⌛ Testing commit 820e3a8 with merge e10eab5...

@bors
Copy link
Contributor

bors commented Mar 25, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Mar 25, 2023

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

@bors bors added merged-by-bors This PR was explicitly merged by bors. labels Mar 25, 2023
@bors bors merged commit e10eab5 into rust-lang:master Mar 25, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 25, 2023
@Zoxc Zoxc deleted the verify-hash-opt branch March 25, 2023 12:06
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e10eab5): 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.9% [-1.6%, -0.4%] 78
Improvements ✅
(secondary)
-1.1% [-2.2%, -0.5%] 39
All ❌✅ (primary) -0.9% [-1.6%, -0.4%] 78

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.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.1% [-4.2%, -2.2%] 4
Improvements ✅
(secondary)
-2.4% [-4.4%, -0.5%] 82
All ❌✅ (primary) -2.0% [-4.2%, 2.0%] 5

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.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
0.9% [0.4%, 3.6%] 11
Improvements ✅
(primary)
-0.9% [-1.1%, -0.7%] 2
Improvements ✅
(secondary)
-0.9% [-1.1%, -0.5%] 3
All ❌✅ (primary) -0.2% [-1.1%, 1.1%] 3

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.

8 participants