Skip to content
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

[consensus] batch availability counters for InlineHybrid payload #14853

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
},
);
48 changes: 47 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,52 @@ 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()),
);

// The payload is considered available because it contains only proofs that guarantee network availabiliy
// or inlined transactions.
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
Loading