-
Notifications
You must be signed in to change notification settings - Fork 336
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
Shreds incur extra copies in several places #1142
Comments
At some point in the near future, I'll gather some data with |
Minor note - But, blocks are bigger in number of shreds (and will presumably continue to get bigger as we increase CU limits) based on recent MNB traffic compared to when I first wrote this up. AND, RPC is core infrastructure so there is absolutely benefit in optimizing for these as well. Lastly, |
In regards to this item, data is now copied directly from rocksdb owned memory into the common buffer passed to
So, there is likely not much else to do on this piece.
There is potentially still room for optimization on this aspect though. I will update the issue to reflect that 2. is mostly resolved |
Problem
The shred object currently contains owned memory via a
Vec<u8>
. In several places, shreds are very temporarily created as an intermediate. Given the owned memory, we have extra copies:1. Shred insertion into Blockstore - copy buffers from a
PacketBatch
to individualShred
s:agave/core/src/window_service.rs
Line 333 in 12d009e
The shreds have a short, common lifetime, that ends shortly after this copy. One minor exception is for any duplicate shreds that may be found (the duplicates have some further processing).
2. Shred fetch from Blockstore via
Blockstore::get_slot_entries_in_block()
. UPDATE: this item has been resolved - see #1142 (comment)Original issue description for shred fetch
agave/ledger/src/blockstore_db.rs
Line 1587 in 12d009e
agave/ledger/src/shredder.rs
Lines 404 to 405 in 12d009e
agave/ledger/src/blockstore.rs
Lines 3579 to 3584 in 12d009e
The copy into common buffer (2nd snippet) and bincode deserialize (3rd snippet) are necessary. However, the initial copy to owned memory (1st snippet) is seemingly not necessary. Note that shred fetch occurs for both
ReplayStage
andCompletedDataSetsService
, so the effects of this one are doubled.Impact
Looking at MNB metrics:
recv-window-insert-shreds.num_packets
and datapoint reported every 3 seconds)shred_insert_is_full.last_index
* 2.5 blocks / second).ReplayStage
andCompletedDataSetsService
So, in total, this is about ~5700 allocations and ~6.75 MB of memory copy that could be avoided, per second
Proposed Solution
Rework
Shred
to allow owned or borrowed memory, such as what Cow providesThe text was updated successfully, but these errors were encountered: