Skip to content
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

merkledb -- preallocate bytes.Buffer in codec #1900

Merged
merged 6 commits into from
Aug 24, 2023
Merged

Conversation

danlaine
Copy link

Why this should be merged

May prevent doing some memory allocations

How this works

Self-explanatory

How this was tested

Existing UT

x/merkledb/codec.go Outdated Show resolved Hide resolved
x/merkledb/codec.go Outdated Show resolved Hide resolved
@joshua-kim
Copy link
Contributor

joshua-kim commented Aug 23, 2023

Code looks correct to me but I'm just curious to see if we can get tighter bounds on the pre-allocation to see if we can avoid re-allocations later.

If we're concerned with the performance of our codec here we could also consider adding specific benchmarks tests for the codec to see if this is helping us.

@danlaine
Copy link
Author

@joshua-kim Added estimates based on the number of children

@danlaine
Copy link
Author

For what it's worth I expect this to be a pretty modest speedup. If we find that we're doing a ton of memory allocations here we can always bump the size estimates.

@danlaine danlaine merged commit edb115e into dev Aug 24, 2023
16 checks passed
@danlaine danlaine deleted the merkledb-prealloc-codec branch August 24, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants