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

getTokenLargestAccounts may do a large sort and does bs58 on every account #34584

Closed
cavemanloverboy opened this issue Dec 23, 2023 · 1 comment
Labels
community Community contribution

Comments

@cavemanloverboy
Copy link
Contributor

Problem
The getTokenLargestAccounts rpc method gathers all token accounts belonging to a mint, sorts the complete list, and then truncates the list. This is no bueno, because only a partial sort needs to be done. This partial sort can be accomplished by maintaining a fixed-size min heap. It also does the pubkey base58 for all token accounts (and some other minor string allocations) regardless of whether they are in the set of largest accounts.

Summary of Changes
Use a fixed-size min heap to track largest token accounts. Only do base58 encoding of pubkeys for accounts that are in the heap (as I write this, I realize this could be deferred further until the top accounts are obtained).

Fixed in #34583

@cavemanloverboy cavemanloverboy added the community Community contribution label Dec 23, 2023
@cavemanloverboy cavemanloverboy changed the title getTokenLargestAccounts may do a large sort getTokenLargestAccounts may do a large sort and does bs58 on every account Dec 23, 2023
@nickfrosty
Copy link
Contributor

This appears to now be fully fixed in #35263 and #35264

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

Successfully merging a pull request may close this issue.

2 participants