aligned_memory: use calloc to get zeroed memory #360
Merged
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.
Use
calloc()
instead of usingmalloc()
+memset()
. The former gets zeroed memory straight from the OS, avoids writing the memory twice (once to clear old content, once to zero it) and avoids actually paging in the whole new allocation due tomemset
. See rust-lang/rust#54628.In practical terms, this halves memset usage while executing transactions, eliminating a frequent largeish memset in
CallFrames::new
.Before:
After:
You can see that
memset_avx2_erms
is cut in half, andCallFrames::new()
no longer shows up in profiles. (As for the other memsets, we'll probably be able to remove them when we implement unaligned memory mapping)