From e104646d95dc74b388e7dd328cb2cc1abd436e2b Mon Sep 17 00:00:00 2001 From: "Brian (Sunghoon) Cho" Date: Fri, 4 Aug 2023 09:01:03 -0700 Subject: [PATCH] [Mempool] Don't log times that are <= 0 for insertion time to block timestamp (#9482) ### Description This happens due to retry/duplication and should be ignored (instead of logging time 0). This cleans up the metric a bit, especially for forge tests that have enough latency that causes frequent transaction retries. --- mempool/src/core_mempool/mempool.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mempool/src/core_mempool/mempool.rs b/mempool/src/core_mempool/mempool.rs index b9efde06bf00a..26ccf3d233bc6 100644 --- a/mempool/src/core_mempool/mempool.rs +++ b/mempool/src/core_mempool/mempool.rs @@ -156,12 +156,14 @@ impl Mempool { let insertion_timestamp = aptos_infallible::duration_since_epoch_at(&insertion_info.insertion_time); - counters::core_mempool_txn_commit_latency( - counters::COMMIT_ACCEPTED_BLOCK_LABEL, - insertion_info.submitted_by_label(), - bucket, - block_timestamp.saturating_sub(insertion_timestamp), - ); + if let Some(insertion_to_block) = block_timestamp.checked_sub(insertion_timestamp) { + counters::core_mempool_txn_commit_latency( + counters::COMMIT_ACCEPTED_BLOCK_LABEL, + insertion_info.submitted_by_label(), + bucket, + insertion_to_block, + ); + } } }