-
-
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
Don't store full pubkey in pubkey2index map #3039
Comments
Proposal:
Since the goal of this Map is to speed up lookup by pubkeys narrowing down from 250_000 to ~10 instead of 1 is good enough. Analysis of probabilities should pick an appropriate byte length. Also must check that BLS pubkeys have a sufficient random distribution of the first N bytes. |
After doing some research today:
WIP branch: https://github.com/ChainSafe/lodestar/tree/dapplion/pubkey2index-short-key |
The real cause of the memory inefficiency is the concatenated strings as shown here #3446 The current size of the Pubkey2Index map is 45.5MB for 275496 validators. We could consider reducing the pubkey length but now it's not that prioritary |
Is this a worthy optimisation for memory? Need to investigate further. |
|
Describe the feature
We don't need to store the full pubkey since the collision probability is low enough with just a few bytes. Note that ethereum addresses use 20 bytes only.
Check a safe minimum byte count and create a map that can extend the size of the key if it detects a collision. Keep an array of key bytes, starting at [10] for example, and if there's a collision extend to [11] and write new keys with 11 bytes. Then to check slice to 11 check, slice to 10 check.
The text was updated successfully, but these errors were encountered: