From b7baf3526db482e0957629c212f1700c96e829b2 Mon Sep 17 00:00:00 2001 From: igor-aptos <110557261+igor-aptos@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:16:25 -0700 Subject: [PATCH] Improve QS backpressure counter (#13998) --- consensus/src/quorum_store/batch_generator.rs | 6 +++++- consensus/src/quorum_store/counters.rs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/consensus/src/quorum_store/batch_generator.rs b/consensus/src/quorum_store/batch_generator.rs index ae59c83166fb5..b163709a74b5e 100644 --- a/consensus/src/quorum_store/batch_generator.rs +++ b/consensus/src/quorum_store/batch_generator.rs @@ -425,6 +425,7 @@ impl BatchGenerator { trace!("QS: dynamic_max_pull_txn_per_s: {}", dynamic_pull_txn_per_s); } counters::QS_BACKPRESSURE_TXN_COUNT.observe(1.0); + counters::QS_BACKPRESSURE_MAKE_STRICTER_TXN_COUNT.observe(1.0); counters::QS_BACKPRESSURE_DYNAMIC_MAX.observe(dynamic_pull_txn_per_s as f64); } else { // additive increase, every second @@ -436,7 +437,10 @@ impl BatchGenerator { ); trace!("QS: dynamic_max_pull_txn_per_s: {}", dynamic_pull_txn_per_s); } - counters::QS_BACKPRESSURE_TXN_COUNT.observe(0.0); + counters::QS_BACKPRESSURE_TXN_COUNT.observe( + if dynamic_pull_txn_per_s < self.config.back_pressure.dynamic_max_txn_per_s { 1.0 } else { 0.0 } + ); + counters::QS_BACKPRESSURE_MAKE_STRICTER_TXN_COUNT.observe(0.0); counters::QS_BACKPRESSURE_DYNAMIC_MAX.observe(dynamic_pull_txn_per_s as f64); } if self.back_pressure.proof_count { diff --git a/consensus/src/quorum_store/counters.rs b/consensus/src/quorum_store/counters.rs index 3325659ffd3cf..67674cb7cdcff 100644 --- a/consensus/src/quorum_store/counters.rs +++ b/consensus/src/quorum_store/counters.rs @@ -752,6 +752,13 @@ pub static QS_BACKPRESSURE_TXN_COUNT: Lazy = Lazy::new(|| { ) }); +pub static QS_BACKPRESSURE_MAKE_STRICTER_TXN_COUNT: Lazy = Lazy::new(|| { + register_avg_counter( + "quorum_store_backpressure_make_stricter_txn_count", + "Indicator of whether Quorum Store txn count backpressure is being made stricter.", + ) +}); + pub static QS_BACKPRESSURE_PROOF_COUNT: Lazy = Lazy::new(|| { register_avg_counter( "quorum_store_backpressure_proof_count",