-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
Use memory efficient toHex in pubkey2index map #3561
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3561 +/- ##
=======================================
Coverage 37.47% 37.47%
=======================================
Files 311 311
Lines 8291 8291
Branches 1282 1282
=======================================
Hits 3107 3107
Misses 5036 5036
Partials 148 148 |
Code Climate has analyzed commit f5b920c and detected 0 issues on this pull request. View more on Code Climate. |
Performance Report✔️ no performance regression detected Full benchmark results
|
@@ -0,0 +1,215 @@ | |||
export type TestRunnerMemoryOpts<T> = { |
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.
When you're ready, maybe this should be pulled into its own package. I see you're using it in ssz too here
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.
Agree it should eventually, tho it still needs more testing.
Motivation
From the benchmarks in #3446 it's shown that concatenated strings take significant more memory than a string produced with Buffer.toString(). NodeJS's Buffer uses C++ bindings to produce the hex strings thus the different result.
For a network with 250_000 the concatenated strings for the pubkeys alone take 1400 * 250_000 = 350 MB.
Description
This PR should be followed by a general replacement of toHexString by this memory efficient approach. However, this PR does this minimal change first since pubkey2index takes the bulk of memory usage for concatenated strings.