-
Notifications
You must be signed in to change notification settings - Fork 186
perf: Use a Vec
for CycleHeads
#760
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
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
CodSpeed Performance ReportMerging #760 will improve performances by 5.54%Comparing Summary
Benchmarks breakdown
|
90345f4
to
de19b2e
Compare
The number of cycle participants is generally low so a hashset likely has more overhead compared to a simple vec
de19b2e
to
b4929f1
Compare
Vec
for CycleHeads
ThinVec
for CycleHeads
d5efeed
to
f96b9cc
Compare
ThinVec
for CycleHeads
Vec
for CycleHeads
f96b9cc
to
efec0f9
Compare
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.
Looks great, thank you!
pub(crate) struct CycleHeadsIter<'a>( | ||
Option<std::collections::hash_set::Iter<'a, DatabaseKeyIndex>>, | ||
); | ||
pub struct CycleHeadsIter<'a>(std::slice::Iter<'a, DatabaseKeyIndex>); |
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 don't know if you consider this an improvement, but we can eliminate CycleHeadsIter
and implement IntoIterator
for &'a CycleHeads
like so:
impl<'a> std::iter::IntoIterator for &'a CycleHeads {
type Item = DatabaseKeyIndex;
type IntoIter = std::iter::Copied<std::slice::Iter<'a, DatabaseKeyIndex>>;
fn into_iter(self) -> Self::IntoIter {
self.0
.as_ref()
.map(|heads| heads.iter())
.unwrap_or_default()
.copied()
}
}
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.
This causes new[InternedInput]
to regress due to a report_tracked_read
becoming more expensive, so something optimizes differently there 😕 Will drop our Extend
impl as we can optimize around knowing the concrete iterator anyways.
7e21992
to
79505fc
Compare
2f37075
to
7e21992
Compare
5a5a6d0
to
973c711
Compare
973c711
to
5b718d7
Compare
The number of cycle participants is generally low so a hashset likely has more overhead compared to a simple vec for such small numbers of elements.