forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blockstore: Move rocksdb keys from heap to stack (#3603)
Each column in the Blockstore declares an Index type in its Column trait implementation. For example, the Index type for data shreds is a tuple, (slot, shred_index). Under the hood, rocksdb just wants a &[u8] for the key. To do the translation, the Column trait also has a function that converts Index ==> Vec<u8>. Returning a Vec<u8> for each of these incurs a heap allocation. But, the size of the key byte array is constant per column, and can also be known at compile time. So, this change parameterizes LedgerColumn with a const value K, where K is the known size of keys for that column. With a constant value, we can use [u8; K] instead of Vec's and utilize the stack over the heap. This change shifted the majority of the call locations to use the stack based approach, but there are several locations left that will be updated in subsequent changes
- Loading branch information
Showing
2 changed files
with
164 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.