Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 31b3e0e

Browse files
authored
adds metric tracking wasted data buffer in shreds (#25972)
1 parent a9c9acf commit 31b3e0e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ledger/src/shred/stats.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub struct ProcessShredsStats {
2323
num_residual_data_shreds: [usize; 4],
2424
// If the blockstore already has shreds for the broadcast slot.
2525
pub num_extant_slots: u64,
26+
pub(crate) data_buffer_residual: usize,
2627
}
2728

2829
#[derive(Default, Debug, Eq, PartialEq)]
@@ -70,6 +71,7 @@ impl ProcessShredsStats {
7071
("sign_coding_time", self.sign_coding_elapsed, i64),
7172
("coding_send_time", self.coding_send_elapsed, i64),
7273
("num_extant_slots", self.num_extant_slots, i64),
74+
("data_buffer_residual", self.data_buffer_residual, i64),
7375
(
7476
"residual_data_shreds_08",
7577
self.num_residual_data_shreds[0],
@@ -137,6 +139,7 @@ impl AddAssign<ProcessShredsStats> for ProcessShredsStats {
137139
get_leader_schedule_elapsed,
138140
num_residual_data_shreds,
139141
num_extant_slots,
142+
data_buffer_residual,
140143
} = rhs;
141144
self.shredding_elapsed += shredding_elapsed;
142145
self.receive_elapsed += receive_elapsed;
@@ -147,6 +150,7 @@ impl AddAssign<ProcessShredsStats> for ProcessShredsStats {
147150
self.coding_send_elapsed += coding_send_elapsed;
148151
self.get_leader_schedule_elapsed += get_leader_schedule_elapsed;
149152
self.num_extant_slots += num_extant_slots;
153+
self.data_buffer_residual += data_buffer_residual;
150154
for (i, bucket) in self.num_residual_data_shreds.iter_mut().enumerate() {
151155
*bucket += num_residual_data_shreds[i];
152156
}

ledger/src/shredder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ impl Shredder {
112112

113113
let mut gen_data_time = Measure::start("shred_gen_data_time");
114114
let data_buffer_size = ShredData::capacity(/*merkle_proof_size:*/ None).unwrap();
115+
process_stats.data_buffer_residual +=
116+
(data_buffer_size - serialized_shreds.len() % data_buffer_size) % data_buffer_size;
115117
// Integer division to ensure we have enough shreds to fit all the data
116118
let num_shreds = (serialized_shreds.len() + data_buffer_size - 1) / data_buffer_size;
117119
let last_shred_index = next_shred_index + num_shreds as u32 - 1;

0 commit comments

Comments
 (0)