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

Add ByteVectorShared - optimize validator object memory #226

Open
dapplion opened this issue Jan 17, 2022 · 0 comments
Open

Add ByteVectorShared - optimize validator object memory #226

dapplion opened this issue Jan 17, 2022 · 0 comments

Comments

@dapplion
Copy link
Contributor

NodeJS represents Uint8Arrays inefficiently when they have small sizes. The validators object have pubkey and withdrawal_credentials that can be thought as an append-only list which take ~140MB in a single state.

An optimization to reduce their memory cost is to keep them in bigger Uint8Arrays that are shared for multiple pubkeys. This is possible as quickly tested in https://github.com/ChainSafe/ssz/tree/dapplion/byteVectorImmutable

Since validator objects are already represented as values internally inside a node the validator object could be a custom class instance with getters for pubkey and withdrawal_credentials that slice a Uint8Array of the shared one.

@dapplion dapplion changed the title Add ByteVectorShared Add ByteVectorShared - optimize validator object memory Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants