Skip to content

Commit

Permalink
Pull from mempool more frequently (aptos-labs#14109)
Browse files Browse the repository at this point in the history
Pull from mempool more frequently
  • Loading branch information
vusirikala authored Jul 29, 2024
1 parent 4b42525 commit 6d0d9ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion config/src/config/quorum_store_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct QuorumStoreBackPressureConfig {
pub decrease_fraction: f64,
pub dynamic_min_txn_per_s: u64,
pub dynamic_max_txn_per_s: u64,
pub additive_increase_when_no_backpressure: u64,
}

impl Default for QuorumStoreBackPressureConfig {
Expand All @@ -38,6 +39,9 @@ impl Default for QuorumStoreBackPressureConfig {
decrease_fraction: 0.5,
dynamic_min_txn_per_s: 160,
dynamic_max_txn_per_s: 12000,
// When the QS is no longer backpressured, we increase number of txns to be pulled from mempool
// by this amount every second until we reach dynamic_max_txn_per_s
additive_increase_when_no_backpressure: 2000,
}
}
}
Expand Down Expand Up @@ -100,7 +104,7 @@ impl Default for QuorumStoreConfig {
channel_size: 1000,
proof_timeout_ms: 10000,
batch_generation_poll_interval_ms: 25,
batch_generation_min_non_empty_interval_ms: 200,
batch_generation_min_non_empty_interval_ms: 100,
batch_generation_max_interval_ms: 250,
sender_max_batch_txns: DEFEAULT_MAX_BATCH_TXNS,
// TODO: on next release, remove BATCH_PADDING_BYTES
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/quorum_store/batch_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl BatchGenerator {
if back_pressure_increase_latest.elapsed() >= back_pressure_increase_duration {
back_pressure_increase_latest = tick_start;
dynamic_pull_txn_per_s = std::cmp::min(
dynamic_pull_txn_per_s + self.config.back_pressure.dynamic_min_txn_per_s,
dynamic_pull_txn_per_s + self.config.back_pressure.additive_increase_when_no_backpressure,
self.config.back_pressure.dynamic_max_txn_per_s,
);
trace!("QS: dynamic_max_pull_txn_per_s: {}", dynamic_pull_txn_per_s);
Expand Down
16 changes: 16 additions & 0 deletions consensus/src/quorum_store/proof_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::{
cmp::min,
collections::{BTreeMap, HashMap, HashSet},
sync::Arc,
time::Duration,
};

#[derive(Debug)]
Expand Down Expand Up @@ -298,6 +299,21 @@ impl ProofManager {

/// return true when quorum store is back pressured
pub(crate) fn qs_back_pressure(&self) -> BackPressure {
if self.remaining_total_txn_num > self.back_pressure_total_txn_limit
|| self.remaining_total_proof_num > self.back_pressure_total_proof_limit
{
sample!(
SampleRate::Duration(Duration::from_millis(200)),
info!(
"Quorum store is back pressured with {} txns, limit: {}, proofs: {}, limit: {}",
self.remaining_total_txn_num,
self.back_pressure_total_txn_limit,
self.remaining_total_proof_num,
self.back_pressure_total_proof_limit
);
);
}

BackPressure {
txn_count: self.remaining_total_txn_num > self.back_pressure_total_txn_limit,
proof_count: self.remaining_total_proof_num > self.back_pressure_total_proof_limit,
Expand Down

0 comments on commit 6d0d9ff

Please sign in to comment.