adds metrics for num merkle shreds on the receiving end (#29710)

This commit is contained in:
behzad nouri 2023-01-14 23:07:42 +00:00 committed by GitHub
parent d4ce59eee7
commit 5b5a3ebce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -19,7 +19,6 @@ use {
};
const DEFAULT_LRU_SIZE: usize = 10_000;
type ShredsReceived = LruCache<u64, ()>;
pub(crate) struct ShredFetchStage {
thread_hdls: Vec<JoinHandle<()>>,
@ -229,7 +228,7 @@ fn should_discard_packet(
max_slot: Slot, // Max slot to ingest shreds for.
shred_version: u16,
packet_hasher: &PacketHasher,
shreds_received: &mut ShredsReceived,
shreds_received: &mut LruCache<u64, ()>,
stats: &mut ShredFetchStats,
) -> bool {
if should_discard_shred(packet, root, max_slot, shred_version, stats) {

View File

@ -912,8 +912,8 @@ pub fn should_discard_shred(
}
}
}
let shred_type = match layout::get_shred_type(shred) {
Ok(shred_type) => shred_type,
let shred_variant = match layout::get_shred_variant(shred) {
Ok(shred_variant) => shred_variant,
Err(_) => {
stats.bad_shred_type += 1;
return true;
@ -939,7 +939,7 @@ pub fn should_discard_shred(
return true;
}
};
match shred_type {
match ShredType::from(shred_variant) {
ShredType::Code => {
if index >= shred_code::MAX_CODE_SHREDS_PER_SLOT as u32 {
stats.index_out_of_bounds += 1;
@ -975,6 +975,15 @@ pub fn should_discard_shred(
}
}
}
match shred_variant {
ShredVariant::LegacyCode | ShredVariant::LegacyData => (),
ShredVariant::MerkleCode(_) => {
stats.num_shreds_merkle_code = stats.num_shreds_merkle_code.saturating_add(1);
}
ShredVariant::MerkleData(_) => {
stats.num_shreds_merkle_data = stats.num_shreds_merkle_data.saturating_add(1);
}
}
false
}

View File

@ -32,6 +32,8 @@ pub struct ProcessShredsStats {
pub struct ShredFetchStats {
pub index_overrun: usize,
pub shred_count: usize,
pub(crate) num_shreds_merkle_code: usize,
pub(crate) num_shreds_merkle_data: usize,
pub ping_count: usize,
pub ping_err_verify_count: usize,
pub(crate) index_bad_deserialize: usize,
@ -115,6 +117,8 @@ impl ShredFetchStats {
name,
("index_overrun", self.index_overrun, i64),
("shred_count", self.shred_count, i64),
("num_shreds_merkle_code", self.num_shreds_merkle_code, i64),
("num_shreds_merkle_data", self.num_shreds_merkle_data, i64),
("ping_count", self.ping_count, i64),
("ping_err_verify_count", self.ping_err_verify_count, i64),
("slot_bad_deserialize", self.slot_bad_deserialize, i64),