You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Shred insertion into Blockstore - copy buffers from a PacketBatch to individual Shreds:
For 1., 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).
For 2., 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 and CompletedDataSetsService, so the effects of this one are doubled.
Looking at MNB metrics:
I see about ~2700 packets / second coming through (8k on recv-window-insert-shreds.num_packets and datapoint reported every 3 seconds)
I see about ~1500 shreds / second (600 for shred_insert_is_full.last_index * 2.5 blocks / second).
Again, for below calculation, double this number because of ReplayStage and CompletedDataSetsService
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 provides
The text was updated successfully, but these errors were encountered:
At some point in the near future, I'll gather some data with perf so we can get a better idea of how much the previously mentioned numbers contribute to overall process numbers. Doing so might help us attach some sense of priority (ie if these are 0.01% of all allocations, we might decide we have bigger fish to fry at the moment).
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:Shred insertion into Blockstore - copy buffers from a
PacketBatch
to individualShred
s:agave/core/src/window_service.rs
Line 333 in 12d009e
Shred fetch from Blockstore via
Blockstore::get_slot_entries_in_block()
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
For 1., 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).
For 2., 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.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: