diff --git a/crates/metrics/src/txpool_metrics.rs b/crates/metrics/src/txpool_metrics.rs index 79e21762398..c7fddc501f0 100644 --- a/crates/metrics/src/txpool_metrics.rs +++ b/crates/metrics/src/txpool_metrics.rs @@ -23,18 +23,18 @@ pub struct TxPoolMetrics { /// Time of transactions in the txpool in seconds pub transaction_time_in_txpool_secs: Histogram, /// Time actively spent by transaction insertion in the thread pool - pub transaction_insertion_time_in_thread_pool_milliseconds: Histogram, + pub transaction_insertion_time_in_thread_pool_microseconds: Histogram, /// How long it took for the selection algorithm to select transactions - pub select_transactions_time_nanoseconds: Histogram, + pub select_transactions_time_microseconds: Histogram, } impl Default for TxPoolMetrics { fn default() -> Self { let tx_size = Histogram::new(buckets(Buckets::TransactionSize)); let transaction_time_in_txpool_secs = Histogram::new(buckets(Buckets::Timing)); - let select_transactions_time_nanoseconds = + let select_transactions_time_microseconds = Histogram::new(buckets(Buckets::TimingCoarseGrained)); - let transaction_insertion_time_in_thread_pool_milliseconds = + let transaction_insertion_time_in_thread_pool_microseconds = Histogram::new(buckets(Buckets::TimingCoarseGrained)); let number_of_transactions = Gauge::default(); @@ -47,8 +47,8 @@ impl Default for TxPoolMetrics { number_of_transactions_pending_verification, number_of_executable_transactions, transaction_time_in_txpool_secs, - transaction_insertion_time_in_thread_pool_milliseconds, - select_transactions_time_nanoseconds, + transaction_insertion_time_in_thread_pool_microseconds, + select_transactions_time_microseconds, }; let mut registry = global_registry().registry.lock(); @@ -83,16 +83,16 @@ impl Default for TxPoolMetrics { ); registry.register( - "txpool_select_transactions_time_nanoseconds", - "The time it took to select transactions for inclusion in a block in nanoseconds", - metrics.select_transactions_time_nanoseconds.clone(), + "txpool_select_transactions_time_microseconds", + "The time it took to select transactions for inclusion in a block in microseconds", + metrics.select_transactions_time_microseconds.clone(), ); registry.register( - "txpool_insert_transaction_time_milliseconds", - "The time it took to insert a transaction in the txpool in milliseconds", + "txpool_transaction_insertion_time_in_thread_pool_microseconds", + "The time it took to insert a transaction in the txpool in microseconds", metrics - .transaction_insertion_time_in_thread_pool_milliseconds + .transaction_insertion_time_in_thread_pool_microseconds .clone(), ); diff --git a/crates/services/txpool_v2/src/pool.rs b/crates/services/txpool_v2/src/pool.rs index 691adf3e75f..3e26d844a98 100644 --- a/crates/services/txpool_v2/src/pool.rs +++ b/crates/services/txpool_v2/src/pool.rs @@ -257,10 +257,10 @@ where } } - fn record_select_transaction_time_in_nanoseconds(start: Instant) { - let elapsed = start.elapsed().as_nanos() as f64; + fn record_select_transaction_time(start: Instant) { + let elapsed = start.elapsed().as_micros() as f64; txpool_metrics() - .select_transactions_time_nanoseconds + .select_transactions_time_microseconds .observe(elapsed); } @@ -292,7 +292,7 @@ where .selection_algorithm .gather_best_txs(constraints, &mut self.storage); if let Some(start) = maybe_start { - Self::record_select_transaction_time_in_nanoseconds(start) + Self::record_select_transaction_time(start) }; if metrics { diff --git a/crates/services/txpool_v2/src/service.rs b/crates/services/txpool_v2/src/service.rs index 23009fb4e03..538a50f6ee6 100644 --- a/crates/services/txpool_v2/src/service.rs +++ b/crates/services/txpool_v2/src/service.rs @@ -482,9 +482,9 @@ where .inc(); let start_time = tokio::time::Instant::now(); insert_transaction_thread_pool_op(); - let time_for_task_to_complete = start_time.elapsed().as_millis(); + let time_for_task_to_complete = start_time.elapsed().as_micros(); txpool_metrics - .transaction_insertion_time_in_thread_pool_milliseconds + .transaction_insertion_time_in_thread_pool_microseconds .observe(time_for_task_to_complete as f64); txpool_metrics .number_of_transactions_pending_verification