-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Perf] Use SmallVec for some temporary allocations #3
base: mainnet-staging
Are you sure you want to change the base?
[Perf] Use SmallVec for some temporary allocations #3
Conversation
16a0ff3
to
8b41f54
Compare
Added a commit with an extra win. |
Do you have a rough guess or estimate of the reduction, like you mention in some other SmallVec PRs?
If the estimation is wrong, I guess we may see reduced performance compared to if we never had this PR right? |
@@ -464,7 +464,7 @@ impl<F: PrimeField, const RATE: usize> PoseidonSponge<F, RATE, 1> { | |||
}; | |||
let bits = self.get_bits(num_bits_per_nonnative * num_elements); | |||
|
|||
let mut lookup_table = Vec::<TargetField>::with_capacity(num_bits_per_nonnative); | |||
let mut lookup_table: SmallVec<[TargetField; 256]> = SmallVec::new(); |
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.
Could it make sense to still use num_bits_per_nonnative
?
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.
sadly, it's not const
, so we can't use it
Some of those sizes (like the number of bits in a |
These were added incrementally while working on the linked PR, but I'm happy to produce some isolated figures; note that in case of these changes it is more practical to provide them for the specific methods, as the impact on node performance heavily depends on the type of workload.
|
Signed-off-by: ljedrz <[email protected]>
Signed-off-by: ljedrz <[email protected]>
Signed-off-by: ljedrz <[email protected]>
Signed-off-by: ljedrz <[email protected]>
8b41f54
to
4c5211c
Compare
Mind closing this and rebasing/re-opening on AleoNet? No rush of course. |
Temporary allocations are ones that are found to be deallocated directly after their creation, meaning they are suitable candidates for a substitution with an array (if the size is known in advance and
const
) or aSmallVec
.This PR applies the latter in two spots that were found to be a source of a significant number of temporary allocations, and the size was chosen based on values observed empirically in a
--dev
run.More
SmallVec
-related changes will follow, but these 2 require no further setup.