From 4b48d25fb49404f36cfba8802d87af2c4a03c226 Mon Sep 17 00:00:00 2001 From: 0g-peterzhb <158457852+0g-peterzhb@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:54:42 +0800 Subject: [PATCH] track tx seq number time consumed (#268) --- node/storage/src/log_store/metrics.rs | 2 ++ node/storage/src/log_store/tx_store.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/node/storage/src/log_store/metrics.rs b/node/storage/src/log_store/metrics.rs index 70ddfda..3e60ad8 100644 --- a/node/storage/src/log_store/metrics.rs +++ b/node/storage/src/log_store/metrics.rs @@ -38,4 +38,6 @@ lazy_static::lazy_static! { pub static ref FINALIZE_TX_WITH_HASH: Arc = register_timer("log_store_log_manager_finalize_tx_with_hash"); pub static ref DATA_TO_MERKLE_LEAVES_SIZE: Arc> = GaugeUsize::register("log_store_data_to_merkle_leaves_size"); + + pub static ref TX_BY_SEQ_NUMBER: Arc = register_timer("log_store_tx_store_get_tx_by_seq_number"); } diff --git a/node/storage/src/log_store/tx_store.rs b/node/storage/src/log_store/tx_store.rs index b238cb7..ea97c1c 100644 --- a/node/storage/src/log_store/tx_store.rs +++ b/node/storage/src/log_store/tx_store.rs @@ -118,11 +118,13 @@ impl TransactionStore { } pub fn get_tx_by_seq_number(&self, seq: u64) -> Result> { + let start_time = Instant::now(); if seq >= self.next_tx_seq() { return Ok(None); } let value = try_option!(self.kvdb.get(COL_TX, &seq.to_be_bytes())?); let tx = Transaction::from_ssz_bytes(&value).map_err(Error::from)?; + metrics::TX_BY_SEQ_NUMBER.update_since(start_time); Ok(Some(tx)) }