Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Optimize MTrie checkpoint: 47x speedup (11.7 hours -> 15 mins), -431 GB alloc/op, -7.6 billion allocs/op, -6.9 GB file size #1944
Optimize MTrie checkpoint: 47x speedup (11.7 hours -> 15 mins), -431 GB alloc/op, -7.6 billion allocs/op, -6.9 GB file size #1944
Changes from 37 commits
04e5c08
dfafbd0
f185fd9
8b03a22
800cca1
422b75b
0b73f52
dd636e5
6c5ad37
3aacebb
c9a8f14
681d9fe
c7c62cd
1b6878e
81ddd43
529b923
889c2f2
51c3249
2d0936c
0cc1ab2
f09677d
2ca95f4
d12c3b3
802347f
aa1549e
f91a1be
2b9d1ae
dcca74e
9d9d2bb
bfa2c67
6618948
0f679fd
65514fa
0ee9675
0f1ba35
c919100
1ebde08
c99bc8c
d3a32c6
6eb8ca9
2c587e6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Wouldn't this avoid the initialization with
nil
?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'm not sure I understand your question.
When slice is created, all elements are initialized with default value even when len=0 and cap>0.
https://go.dev/play/p/vSqQzlyE2Ij
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 think there is a miss-conception involved here. Up to this moment, I also had this (apparently incorrect) assumption:
But your example shows that this assumption is false. Thanks, I learned something 🎉 :
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 @fxamacker for clarifying this mistake! I mistakenly thought that the pattern :
is faster than :
because it avoids the initialization of t. It turns out this is not true!
I've learned something today 🙏🏼
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.
Maybe the same here, since the initialization of arrays can be costly?
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.
See above reply with code snippet.
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.
You're right! I made the same error here!