mirror of
				https://github.com/0glabs/0g-storage-node.git
				synced 2025-10-31 14:47:27 +00:00 
			
		
		
		
	add detailed metrics in slow operations
This commit is contained in:
		
							parent
							
								
									737dd3c44f
								
							
						
					
					
						commit
						9c305a7743
					
				| @ -1,5 +1,5 @@ | |||||||
| use crate::sync_manager::log_query::LogQuery; | use crate::sync_manager::log_query::LogQuery; | ||||||
| use crate::sync_manager::RETRY_WAIT_MS; | use crate::sync_manager::{metrics, RETRY_WAIT_MS}; | ||||||
| use crate::ContractAddress; | use crate::ContractAddress; | ||||||
| use anyhow::{anyhow, bail, Result}; | use anyhow::{anyhow, bail, Result}; | ||||||
| use append_merkle::{Algorithm, Sha3Algorithm}; | use append_merkle::{Algorithm, Sha3Algorithm}; | ||||||
| @ -14,15 +14,12 @@ use shared_types::{DataRoot, Transaction}; | |||||||
| use std::collections::{BTreeMap, HashMap}; | use std::collections::{BTreeMap, HashMap}; | ||||||
| use std::str::FromStr; | use std::str::FromStr; | ||||||
| use std::sync::Arc; | use std::sync::Arc; | ||||||
| use std::time::Duration; | use std::time::{Duration, Instant}; | ||||||
| use storage::log_store::{tx_store::BlockHashAndSubmissionIndex, Store}; | use storage::log_store::{tx_store::BlockHashAndSubmissionIndex, Store}; | ||||||
| use task_executor::TaskExecutor; | use task_executor::TaskExecutor; | ||||||
| use tokio::{ | use tokio::sync::{ | ||||||
|     sync::{ |     mpsc::{UnboundedReceiver, UnboundedSender}, | ||||||
|         mpsc::{UnboundedReceiver, UnboundedSender}, |     RwLock, | ||||||
|         RwLock, |  | ||||||
|     }, |  | ||||||
|     time::Instant, |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| pub struct LogEntryFetcher { | pub struct LogEntryFetcher { | ||||||
| @ -242,6 +239,7 @@ impl LogEntryFetcher { | |||||||
|                 ); |                 ); | ||||||
|                 let (mut block_hash_sent, mut block_number_sent) = (None, None); |                 let (mut block_hash_sent, mut block_number_sent) = (None, None); | ||||||
|                 while let Some(maybe_log) = stream.next().await { |                 while let Some(maybe_log) = stream.next().await { | ||||||
|  |                     let start_time = Instant::now(); | ||||||
|                     match maybe_log { |                     match maybe_log { | ||||||
|                         Ok(log) => { |                         Ok(log) => { | ||||||
|                             let sync_progress = |                             let sync_progress = | ||||||
| @ -301,6 +299,7 @@ impl LogEntryFetcher { | |||||||
|                             tokio::time::sleep(Duration::from_millis(RETRY_WAIT_MS)).await; |                             tokio::time::sleep(Duration::from_millis(RETRY_WAIT_MS)).await; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  |                     metrics::RECOVER_LOG.update_since(start_time); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 info!("log recover end"); |                 info!("log recover end"); | ||||||
|  | |||||||
| @ -8,4 +8,6 @@ lazy_static::lazy_static! { | |||||||
|     pub static ref STORE_PUT_TX: Arc<dyn Timer> = register_timer("log_entry_sync_manager_put_tx_inner"); |     pub static ref STORE_PUT_TX: Arc<dyn Timer> = register_timer("log_entry_sync_manager_put_tx_inner"); | ||||||
| 
 | 
 | ||||||
|     pub static ref STORE_PUT_TX_SPEED_IN_BYTES: Arc<dyn Gauge<usize>> = GaugeUsize::register("log_entry_sync_manager_put_tx_speed_in_bytes"); |     pub static ref STORE_PUT_TX_SPEED_IN_BYTES: Arc<dyn Gauge<usize>> = GaugeUsize::register("log_entry_sync_manager_put_tx_speed_in_bytes"); | ||||||
|  | 
 | ||||||
|  |     pub static ref RECOVER_LOG: Arc<dyn Timer> = register_timer("log_entry_sync_manager_recover_log"); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Peter Zhang
						Peter Zhang