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

Cached stable hash cleanups #95524

Merged
merged 5 commits into from
Apr 9, 2022
Merged

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 31, 2022

r? @nnethercote

Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time.

Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 31, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2022
@nnethercote
Copy link
Contributor

@bors try @rust-timer queue

@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 Mar 31, 2022
@bors
Copy link
Contributor

bors commented Mar 31, 2022

⌛ Trying commit 6ffd654 with merge 0914be4865da468777d1ce5bdd9a546550850308...

@bors
Copy link
Contributor

bors commented Mar 31, 2022

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

@rust-timer
Copy link
Collaborator

Queued 0914be4865da468777d1ce5bdd9a546550850308 with parent 0677edc, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0914be4865da468777d1ce5bdd9a546550850308): comparison url.

Summary: This benchmark run did not return any relevant results.

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.

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

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

The new name helps, thanks.

I'm still a little unclear about the goal here.

  • I can see it's nice to pull the hash out of TyS. Because the hash is auxiliary, rather than being a fundamental part of the type.
  • The PR description says "I pulled out the perf improvement from Also cache the stable hash of interned Predicates #94487" but the perf results are neutral. Is that expected?

/// This is useful if you have values that you intern but never (can?) use for stable
/// hashing.
#[derive(Copy, Clone)]
pub struct TypeAndStableHash<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe call it WithStableHash?

@bjorn3
Copy link
Member

bjorn3 commented Apr 7, 2022

I think @oli-obk means that the perf improvement is not included in this PR and only the refactorings that enable the perf improvement change.

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 7, 2022

Nope, the other PR had a perf improvement for these commits, but that seems to be gone now, maybe it was spurious or randomly dependent on inlining decisions

@nnethercote
Copy link
Contributor

So is this still worthwhile for the conceptual improvement of separating the hash from TyS?

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 7, 2022

Yes, I can investigate perf things independently, editing the main message now to reflect that (and will address bjorn's comments)

@oli-obk oli-obk force-pushed the cached_stable_hash_cleanups branch from 1b638b2 to 2e0ef70 Compare April 7, 2022 13:01
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 7, 2022

Renamed and force pushed

@@ -1266,18 +1266,29 @@ pub trait PrettyPrinter<'tcx>:
ty::Ref(
_,
Ty(Interned(
Copy link
Member

@bjorn3 bjorn3 Apr 7, 2022

Choose a reason for hiding this comment

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

Maybe use nested match with the inner match matching on pointee.kind()? This indentation is getting crazy and pretty unreadable. In addition there are other match arms where the outer type is a reference.

@nnethercote
Copy link
Contributor

Ok by me, I'll let you address @bjorn3's final comment if you want.

@bors delegate+

@bors
Copy link
Contributor

bors commented Apr 7, 2022

✌️ @oli-obk can now approve this pull request

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 8, 2022

@bors r=nnethercote

@bors
Copy link
Contributor

bors commented Apr 8, 2022

📌 Commit 25d6f8e has been approved by nnethercote

@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 Apr 8, 2022
@bors
Copy link
Contributor

bors commented Apr 9, 2022

⌛ Testing commit 25d6f8e with merge e980c62...

@bors
Copy link
Contributor

bors commented Apr 9, 2022

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing e980c62 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 9, 2022
@bors bors merged commit e980c62 into rust-lang:master Apr 9, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 9, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e980c62): comparison url.

Summary:

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 6 6 9 6
mean2 N/A 0.4% -0.3% -0.9% -0.3%
max N/A 0.5% -0.4% -1.3% -0.4%

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

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 21, 2022
…r=nnethercote

Cached stable hash cleanups

r? `@nnethercote`

Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time.

Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
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. 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