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

Increases account hash's stack buffer to hold 200 bytes of data #35394

Closed

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Mar 1, 2024

Problem

When hashing an account, we create a buffer on the stack to reduce the number of unique hash calls to make. The buffer is currently 128 bytes. The metadata fields occupy 81 bytes, which leaves 47 bytes for the account's data.

On mnb today there is approximately 431 million accounts. Of that, approximately 388 million are token accounts. That's 90% of accounts. We should ensure the stack buffer can hold the account data for a token account.

Token accounts have a size of 165 bytes1. This size will be growing though. ATA and Token22 extensions will be larger too. Jon estimates 170-182 bytes is "safe"2.

Also, there are ~1 million stake accounts. They are 200 bytes.

We could size the stack buffer to hold 200 bytes, which will cover the vast majority of accounts. Currently, the vast majority of calls to hash an account have to perform a heap allocation.

TODO: metrics before and after

Summary of Changes

Increases account hash's stack buffer to hold 200 bytes of data

Footnotes

  1. https://github.com/solana-labs/solana-program-library/blob/e651623033fca7997ccd21e55d0f2388473122f9/token/program/src/state.rs#L134

  2. https://discord.com/channels/428295358100013066/977244255212937306/1212827836281524224

@brooksprumo brooksprumo added the work in progress This isn't quite right yet label Mar 1, 2024
@brooksprumo brooksprumo self-assigned this Mar 1, 2024
@brooksprumo brooksprumo removed the work in progress This isn't quite right yet label Mar 1, 2024
@willhickey
Copy link
Contributor

This repository is no longer in use. Please re-open this pull request in the agave repo: https://github.com/anza-xyz/agave

@willhickey willhickey closed this Mar 3, 2024
@brooksprumo brooksprumo deleted the hash/stack-buffer-size branch March 4, 2024 15:37
@brooksprumo
Copy link
Contributor Author

Moved to anza-xyz#56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants