Skip to content

Commit

Permalink
Add sender bucket frequency counter (aptos-labs#14203)
Browse files Browse the repository at this point in the history
  • Loading branch information
vusirikala authored Aug 5, 2024
1 parent 3ec115d commit 06ddae1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mempool/src/core_mempool/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
core_mempool::{
index::TxnPointer,
transaction::{InsertionInfo, MempoolTransaction, TimelineState},
transaction_store::TransactionStore,
transaction_store::{sender_bucket, TransactionStore},
},
counters,
logging::{LogEntry, LogSchema, TxnsLog},
Expand Down Expand Up @@ -319,6 +319,14 @@ impl Mempool {
let now = aptos_infallible::duration_since_epoch().as_millis() as u64;

if status.code == MempoolStatusCode::Accepted {
counters::SENDER_BUCKET_FREQUENCIES
.with_label_values(&[sender_bucket(
&sender,
self.transactions.num_sender_buckets(),
)
.to_string()
.as_str()])
.inc();
if let Some(ready_time_at_sender) = ready_time_at_sender {
let bucket = self.transactions.get_bucket(ranking_score, &sender);
counters::core_mempool_txn_commit_latency(
Expand Down
4 changes: 4 additions & 0 deletions mempool/src/core_mempool/transaction_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ impl TransactionStore {
self.sequence_numbers.get(address)
}

pub(crate) fn num_sender_buckets(&self) -> MempoolSenderBucket {
self.num_sender_buckets
}

/// Insert transaction into TransactionStore. Performs validation checks and updates indexes.
pub(crate) fn insert(&mut self, txn: MempoolTransaction) -> MempoolStatus {
let address = txn.get_sender();
Expand Down
9 changes: 9 additions & 0 deletions mempool/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ pub fn core_mempool_index_size(label: &'static str, size: usize) {
.set(size as i64)
}

pub static SENDER_BUCKET_FREQUENCIES: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
"aptos_core_mempool_sender_bucket_frequencies",
"Frequency of each sender bucket in core mempool",
&["sender_bucket"]
)
.unwrap()
});

/// Counter tracking size of each bucket in timeline index
static CORE_MEMPOOL_TIMELINE_INDEX_SIZE: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
Expand Down

0 comments on commit 06ddae1

Please sign in to comment.