Skip to content

Commit

Permalink
[optqs] proposal status tracker metrics/logs (#15257)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalajiarun authored Nov 13, 2024
1 parent 7d6d59c commit 0746b1b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/src/config/quorum_store_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub struct QuorumStoreConfig {
pub batch_buckets: Vec<u64>,
pub allow_batches_without_pos_in_proposal: bool,
pub enable_opt_quorum_store: bool,
pub opt_qs_minimum_batch_age_usecs: u64,
}

impl Default for QuorumStoreConfig {
Expand Down Expand Up @@ -136,6 +137,7 @@ impl Default for QuorumStoreConfig {
batch_buckets: DEFAULT_BUCKETS.to_vec(),
allow_batches_without_pos_in_proposal: true,
enable_opt_quorum_store: false,
opt_qs_minimum_batch_age_usecs: Duration::from_millis(20).as_micros() as u64,
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions consensus/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,3 +1350,19 @@ pub static CONSENSUS_PROPOSAL_PAYLOAD_BATCH_AVAILABILITY_IN_QS: Lazy<IntCounterV
.unwrap()
},
);

pub static OPTQS_EXCLUDE_AUTHORS_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_optqs_exclude_authors",
"The number of times a batch author appears on the exclude list",
&["author"]
)
.unwrap()
});

pub static OPTQS_LAST_CONSECUTIVE_SUCCESS_COUNT: Lazy<Histogram> = Lazy::new(|| {
register_avg_counter(
"aptos_optqs_last_consecutive_successes",
"The number of last consecutive successes capped at window length",
)
});
1 change: 1 addition & 0 deletions consensus/src/epoch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
)));
let opt_qs_payload_param_provider = Arc::new(OptQSPullParamsProvider::new(
self.config.quorum_store.enable_opt_quorum_store,
self.config.quorum_store.opt_qs_minimum_batch_age_usecs,
failures_tracker.clone(),
));

Expand Down
26 changes: 24 additions & 2 deletions consensus/src/liveness/proposal_status_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
// SPDX-License-Identifier: Apache-2.0

use super::round_state::NewRoundReason;
use crate::counters;
use aptos_collections::BoundedVecDeque;
use aptos_consensus_types::{
common::Author, payload_pull_params::OptQSPayloadPullParams, round_timeout::RoundTimeoutReason,
};
use aptos_infallible::Mutex;
use std::{collections::HashSet, sync::Arc, time::Duration};
use aptos_logger::warn;
use aptos_short_hex_str::AsShortHexStr;
use std::{collections::HashSet, sync::Arc};

pub trait TPastProposalStatusTracker: Send + Sync {
fn push(&self, status: NewRoundReason);
Expand Down Expand Up @@ -103,16 +106,19 @@ impl TPastProposalStatusTracker for Mutex<ExponentialWindowFailureTracker> {

pub struct OptQSPullParamsProvider {
enable_opt_qs: bool,
minimum_batch_age_usecs: u64,
failure_tracker: Arc<Mutex<ExponentialWindowFailureTracker>>,
}

impl OptQSPullParamsProvider {
pub fn new(
enable_opt_qs: bool,
minimum_batch_age_usecs: u64,
failure_tracker: Arc<Mutex<ExponentialWindowFailureTracker>>,
) -> Self {
Self {
enable_opt_qs,
minimum_batch_age_usecs,
failure_tracker,
}
}
Expand All @@ -126,14 +132,30 @@ impl TOptQSPullParamsProvider for OptQSPullParamsProvider {

let tracker = self.failure_tracker.lock();

counters::OPTQS_LAST_CONSECUTIVE_SUCCESS_COUNT
.observe(tracker.last_consecutive_success_count as f64);
if tracker.last_consecutive_success_count < tracker.window {
warn!(
"Skipping OptQS: (last_consecutive_successes) {} < {} (window)",
tracker.last_consecutive_success_count, tracker.window
);
return None;
}

let exclude_authors = tracker.get_exclude_authors();
if !exclude_authors.is_empty() {
let exclude_authors_str: Vec<_> =
exclude_authors.iter().map(|a| a.short_str()).collect();
for author in &exclude_authors_str {
counters::OPTQS_EXCLUDE_AUTHORS_COUNT
.with_label_values(&[author.as_str()])
.inc();
}
warn!("OptQS exclude authors: {:?}", exclude_authors_str);
}
Some(OptQSPayloadPullParams {
exclude_authors,
minimum_batch_age_usecs: Duration::from_millis(10).as_micros() as u64,
minimum_batch_age_usecs: self.minimum_batch_age_usecs,
})
}
}
Expand Down

0 comments on commit 0746b1b

Please sign in to comment.