Skip to content

Commit

Permalink
Perf: modify metric for cachedb (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymousGiga authored Nov 30, 2023
1 parent 41877f1 commit 6885c52
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions bin/reth/src/performance_metrics/dashboard_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,12 @@ impl CacheDBRecordDisplayer {
}
println!();
println!();
let total_ns_count = self.cache_db_record.penalty.us_percentile[0];
println!("========================================Penalty percentile ===============================================");
println!("========================================Penalty percentile(0-4us) ===============================================");
println! {"{: <COL_WIDTH_LARGE$}{:>COL_WIDTH_MIDDLE$}", "time (ns)", "Count (%)"};
for (i, v) in self.cache_db_record.penalty.ns_percentile.iter().enumerate() {
println! {"{: <COL_WIDTH_LARGE$}{:>COL_WIDTH_MIDDLE$.6}", i+1, (*v * 100) as f64 / total_ns_count as f64};
println! {"{: <COL_WIDTH_LARGE$}{:>COL_WIDTH_MIDDLE$.6}", i+1,
(*v * 100) as f64 / total_us_count as f64,
};
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions crates/stages/src/metrics/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ impl ExecutionDurationRecord {
}
/// add
pub fn add(&mut self, other: ExecutionDurationRecord) {
self.execute_inner_time = self.execute_inner_time.checked_add(other.execute_inner_time).expect("overflow");
self.fetching_block_time = self.fetching_block_time.checked_add(other.fetching_block_time).expect("overflow");
self.execution_time = self.execution_time.checked_add(other.execution_time).expect("overflow");
self.process_state_time = self.process_state_time.checked_add(other.process_state_time).expect("overflow");
self.write_to_db_time = self.write_to_db_time.checked_add(other.write_to_db_time).expect("overflow");
self.execute_inner_time =
self.execute_inner_time.checked_add(other.execute_inner_time).expect("overflow");
self.fetching_block_time =
self.fetching_block_time.checked_add(other.fetching_block_time).expect("overflow");
self.execution_time =
self.execution_time.checked_add(other.execution_time).expect("overflow");
self.process_state_time =
self.process_state_time.checked_add(other.process_state_time).expect("overflow");
self.write_to_db_time =
self.write_to_db_time.checked_add(other.write_to_db_time).expect("overflow");
}

fn execute_inner_time(&self) -> f64 {
Expand Down
4 changes: 1 addition & 3 deletions crates/storage/libmdbx-rs/src/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ pub fn add_db_write_record(size: usize, time: Duration) {

/// get db record
pub fn get_db_record() -> (usize, Duration, usize, Duration) {
unsafe {
METRIC_RECORD.get_record()
}
unsafe { METRIC_RECORD.get_record() }
}

pub struct WriteRecord {
Expand Down

0 comments on commit 6885c52

Please sign in to comment.