blockstore: Defer multi_get_bytes() allocation to caller #4674
+27
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
multi_get_bytes()
currently returns owned memory (Vec<u8>
). But, the callers ofmulti_get_bytes()
only require borrowed memory (&[u8]
).Summary of Changes
So,
update multi_get_bytes()
to return a reference to rocksdb owned memory; the caller can copy to owned memory if they require itFuture Work
Some similar work can likely be done with other methods that call
.get_bytes()
. For example, this one here:agave/ledger/src/blockstore.rs
Lines 2266 to 2268 in e48672c
However, the call to
ShredData::resize_stored_shred
requires owned memory, but is only applicable to legacy data shreds as far as I know. Additional rework beyond just changing the underlying rocksdb type will be necessary, so I plan to tackle those in a follow-on PR