-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Reduce memory allocations when computing a tree hash #4976
Reduce memory allocations when computing a tree hash #4976
Conversation
529d087
to
c553279
Compare
865ba6d
to
1333191
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.
This is a solid change. I have one request: please update treehash_test.go
to include actual unit tests for this logic. Right now it doesn't have any real *testing.T
-based tests, it just has a standalone function that you'd have to run manually (that doesn't even assert anything). Since the discrete cases here are basically no hash, one hash, even hashes, and odd hashes, I think a case for each # of input hashes in the range [0,3] should cover everything.
When you do so, please verify that the resulting hashes in both the old and new implementation are identical.
As an aside, v2 of the SDK has this same code for glacier. If you'd like the contribution credit there, please open an identical PR with these changes, otherwise we'll happily do ourselves.
1333191
to
e9b720f
Compare
Hello, @lucix-aws. Thanks for the review. I've added the tests you asked. Also I've tested that the old implementation passes the tests. P.S. I'll open the identical PR for v2 after approval. Thanks for the advice. |
e9b720f
to
917ea3a
Compare
917ea3a
to
97a9620
Compare
97a9620
to
298229f
Compare
@nsofanat1k Thanks again for the contribution. This is good to merge - we plan to do so either later this afternoon or early tomorrow morning. In the meantime, you're free to open the equivalent in v2. |
@nsofanat1k LGTM thanks again for the contribution. @lucix-aws will handle the merge |
Hello. I've decided to rework ComputeTreeHash function because it makes lots of memory allocations.
Benchmark I used:
Benchcmp result: