-
Notifications
You must be signed in to change notification settings - Fork 157
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
Do not re-hash already hashed keys disambiguator and struct identity maps #647
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
CodSpeed Performance ReportMerging #647 will not alter performanceComparing Summary
|
51cdd70
to
67e8cab
Compare
Did you do any perf measurements on ra to verify that the extra complexity and memory usage is worth it? |
Not yet, until r-a can use the master branch salsa, checking anything against r-a is kind of a pain as I'd need to work against david's fork I believe. Either way I'd consider the complexity here rather minor and self-contained (I can clean it up a bit and make it more descriptive if desired) while omitting unnecessary work. So even with perf measurement it should be clear that this skips work imo |
…maps Additionally newtypes these maps
1637c61
to
d717cf8
Compare
src/tracked_struct.rs
Outdated
// conceptually, this contains an `IdentityHash`, but using the type directly will grow the size | ||
// of if this struct by a word due to unusable padding, so we store the fields directly instead. | ||
/// Index of the tracked struct ingredient. |
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.
two nits:
- Phrasing
- Considering moving this comment up to
Identity
's doc comment?
// conceptually, this contains an `IdentityHash`, but using the type directly will grow the size | |
// of if this struct by a word due to unusable padding, so we store the fields directly instead. | |
/// Index of the tracked struct ingredient. | |
/// Index of the tracked struct ingredient. | |
/// | |
/// Conceptually, this contains an `IdentityHash`, but using `IdentityHash` directly will grow the size | |
/// of this struct struct by a `std::mem::size_of::<usize>()` due to unusable padding. To avoid this increase | |
/// in size, `Identity` stores the fields directly instead. |
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 put it outside of the doc comment as this is just an implementation detail, it is not relevant to the ingredient_index
field
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 good to me, modulo documentation and style nits.
src/tracked_struct.rs
Outdated
let eq_module_hash = |k: &Identity| { | ||
k.ingredient_index == key.ingredient_index && k.disambiguator == key.disambiguator | ||
}; | ||
let entry = self.map.raw_entry_mut().from_hash(key.hash, eq_module_hash); |
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.
consider inlining eq_module_hash
?
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.
Oh, that was supposed to be eq_modulo_hash
. I prefer keeping it outside as it documents what we check (also the formatting like this is more readable imo)
src/tracked_struct.rs
Outdated
let eq_module_hash = |k: &Identity| { | ||
k.ingredient_index == key.ingredient_index && k.disambiguator == key.disambiguator | ||
}; |
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.
consider inlining eq_module_hash
?
src/tracked_struct.rs
Outdated
let eq_module_hash = |k: &IdentityHash| k.ingredient_index == key.ingredient_index; | ||
let entry = self.map.raw_entry_mut().from_hash(key.hash, eq_module_hash); |
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.
consider inlining eq_module_hash
?
d717cf8
to
049cb14
Compare
Additionally newtypes these maps.
We got no reason to hash what we already have hashed! (This does need hashbrown as std doesn't stably expose the required API yet)