-
Notifications
You must be signed in to change notification settings - Fork 13k
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 impl Hash for ObligationCauseData
by not hashing ObligationCauseCode
variant fields
#90996
Conversation
selection deduplicates obligations through a hashset at some point, computing the hashes for ObligationCauseCode appears to dominate the hashing cost. bodyid + span + discriminant hash hopefully will sufficiently unique unique enough.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 78b5f2d with merge 4d6fdfcc90813f646820764dbf3cc985d883d9af... |
☀️ Try build successful - checks-actions |
Queued 4d6fdfcc90813f646820764dbf3cc985d883d9af with parent 6414e0b, future comparison URL. |
Huh, this shouldn't need another perf run, I already linked one for this commit in my opening comment.
|
Finished benchmarking commit (4d6fdfcc90813f646820764dbf3cc985d883d9af): comparison url. Summary: This change led to very large relevant mixed results 🤷 in compiler performance.
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 @bors rollup=never |
The wg-grammar change probably is noise since it didn't show up in the previous perf run on the same commit changes. incr-unchanged runs are quite sensitive to the 1/32-randomized incremental cache verification. |
@bors r+ |
📌 Commit 78b5f2d has been approved by |
Should this be marked as relnotes-perf? Documenting diesel was sped up by 58%! (cc @rust-lang/rustdoc) |
Sounds like it is definitely worth mentioning it indeed! |
☀️ Test successful - checks-actions |
Finished benchmarking commit (18fa434): comparison url. Summary: This change led to very large relevant improvements 🎉 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
@@ -123,6 +124,14 @@ pub struct ObligationCauseData<'tcx> { | |||
pub code: ObligationCauseCode<'tcx>, | |||
} | |||
|
|||
impl Hash for ObligationCauseData<'_> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For next time: I suggest leaving a brief comment explaining why this custom hash is used, because it's non-obvious and no fun to have to dig through version control history to understand why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open an issue so it's not forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to adding comments but
no fun to have to dig through version control history
seems a bit subjective, for me that's 3 clicks which is hardly onerous. So that didn't quite meet my threshold of adding a comment.
Split out from #90913 since it's a clear performance win and should be easier to review.
It speeds up hashing for
Obligation
deduplication by only hashing the discriminant of theObligationCauseCode
enum instead of its contents. That shouldn't affect hash quality much since there are several other fields inObligation
which should be unique enough, especially the predicate itself which is hashed as an interned pointer.