Skip to content

Commit

Permalink
[consensus] batch availability counters for InlineHybrid payload
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalajiarun committed Oct 2, 2024
1 parent 18bcbd2 commit 2de9cc7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
11 changes: 11 additions & 0 deletions consensus/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,3 +1311,14 @@ pub static CONSENSUS_PROPOSAL_PAYLOAD_FETCH_DURATION: Lazy<HistogramVec> = Lazy:
)
.unwrap()
});

pub static CONSENSUS_PROPOSAL_PAYLOAD_BATCH_AVAILABILITY_IN_QS: Lazy<IntCounterVec> = Lazy::new(
|| {
register_int_counter_vec!(
"aptos_consensus_proposal_payload_batch_availability",
"The number of batches in payload that are available and missing locally by batch author",
&["author", "is_proof", "state"]
)
.unwrap()
},
);
46 changes: 45 additions & 1 deletion consensus/src/payload_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use aptos_logger::prelude::*;
use aptos_types::{transaction::SignedTransaction, PeerId};
use async_trait::async_trait;
use futures::{channel::mpsc::Sender, FutureExt};
use itertools::Itertools;
use std::{
collections::{btree_map::Entry, BTreeMap},
ops::Deref,
Expand Down Expand Up @@ -305,7 +306,50 @@ impl TPayloadManager for QuorumStorePayloadManager {
},
Payload::InQuorumStore(_) => true,
Payload::InQuorumStoreWithLimit(_) => true,
Payload::QuorumStoreInlineHybrid(_, _, _) => true,
Payload::QuorumStoreInlineHybrid(inline_batches, proofs, _) => {
fn update_availability_metrics<'a>(
batch_reader: &Arc<dyn BatchReader>,
is_proof_label: &str,
total_count: usize,
batch_infos: impl Iterator<Item = &'a BatchInfo>,
) {
for (author, chunk) in &batch_infos.chunk_by(|info| info.author()) {
let available_count = chunk
.filter_map(|info| batch_reader.exists(info.digest()))
.count();
let missing_count = total_count - available_count;
counters::CONSENSUS_PROPOSAL_PAYLOAD_BATCH_AVAILABILITY_IN_QS
.with_label_values(&[
&author.to_hex_literal(),
is_proof_label,
"available",
])
.inc_by(available_count as u64);
counters::CONSENSUS_PROPOSAL_PAYLOAD_BATCH_AVAILABILITY_IN_QS
.with_label_values(&[
&author.to_hex_literal(),
is_proof_label,
"missing",
])
.inc_by(missing_count as u64);
}
}

update_availability_metrics(
&self.batch_reader,
"false",
inline_batches.len(),
inline_batches.iter().map(|(batch_info, _)| batch_info),
);
update_availability_metrics(
&self.batch_reader,
"true",
proofs.proofs.len(),
proofs.proofs.iter().map(|proof| proof.info()),
);

true
},
Payload::OptQuorumStore(opt_qs_payload) => {
for batch in opt_qs_payload.opt_batches().deref() {
if self.batch_reader.exists(batch.digest()).is_none() {
Expand Down

0 comments on commit 2de9cc7

Please sign in to comment.