getTokenLargestAccounts
may do a large sort and does bs58 on every account
#34584
Labels
community
Community contribution
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
The text was updated successfully, but these errors were encountered: