-
Notifications
You must be signed in to change notification settings - Fork 92
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: avoid temporary Vec allocations when computing commitments #939
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #939 +/- ##
==========================================
+ Coverage 67.73% 67.80% +0.07%
==========================================
Files 130 130
Lines 16397 16418 +21
==========================================
+ Hits 11106 11133 +27
+ Misses 5291 5285 -6
☔ View full report in Codecov by Sentry. |
6a6c0f9
to
e54a3a4
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.
Thanks @mina86! Left a few suggestions.
Also, for our context, appreciate let us know what led to this change? Have you established any kind of benchmarks or obtained a preliminary estimate of the impact this change will have on your project's performance?
sha2::Sha256::digest(data).to_vec() | ||
} | ||
|
||
#[test] |
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.
As for the tests, I’d like to have @rnbguy's input!
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.
The test here was purely to make sure that the output doesn’t change during refactoring. I can split this PR into two (one adding the test and the other doing the refactoring) if that’d help to demonstrate it.
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.
@mina86 can you please put the tests under
#[cfg(test)]
mod test { ... }
and, make two separate tests for compute_packet_commitment
and compute_ack_commitment
?
No, this was purely from looking at the code. I’ve done no benchmarks on it. The reason why I was looking at the code was because I needed to make sure commitments are always 32-byte long. By the way, ideally I’d like commitment to be |
Alright, Gotcha.
I see where you are coming from. Exactly, this is a totally different topic and a critical one. Better to surface it later when we have enough bandwidth to fully evaluate the changes around. |
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.
Great PR, @mina86 ! 🙏 Just requested some changes.
sha2::Sha256::digest(data).to_vec() | ||
} | ||
|
||
#[test] |
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.
@mina86 can you please put the tests under
#[cfg(test)]
mod test { ... }
and, make two separate tests for compute_packet_commitment
and compute_ack_commitment
?
Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]>
Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]>
Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]>
Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]>
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.
Awesome! Thanks @mina86 🤝
* perf: avoid temporary Vec allocations when computing commitments * review * Update crates/ibc/src/core/ics04_channel/commitment.rs Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]> * Update crates/ibc/src/core/ics04_channel/commitment.rs Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]> * Update crates/ibc/src/core/ics04_channel/commitment.rs Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]> * review * Update .changelog/unreleased/improvements/939-less-alloc.md Co-authored-by: Rano | Ranadeep <[email protected]> Signed-off-by: Michal Nazarewicz <[email protected]> --------- Signed-off-by: Michal Nazarewicz <[email protected]> Co-authored-by: Rano | Ranadeep <[email protected]>
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.