Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: record save_cache duration metrics #14281

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/engine/tree/src/tree/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ pub(crate) struct BlockValidationMetrics {
/// Prewarm spawn duration
pub(crate) prewarm_spawn_duration: Gauge,
/// Cache saving duration
#[allow(dead_code)]
pub(crate) cache_saving_duration: Gauge,
/// State root config creation duration
pub(crate) state_root_config_duration: Gauge,
Expand Down
5 changes: 5 additions & 0 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,7 @@ where
debug!(target: "engine::tree", ?root_elapsed, block=?block_num_hash, "Calculated state root");

if self.config.use_caching_and_prewarming() {
let save_cache_start = Instant::now();
// this is the only place / thread a writer is acquired, so we would have already
// crashed if we had a poisoned rwlock
//
Expand All @@ -2581,6 +2582,10 @@ where
// apply state updates to cache and save it (if saving was successful)
self.most_recent_cache =
state_provider.save_cache(sealed_block.hash(), &output.state).ok();
let elapsed = save_cache_start.elapsed();

// record how long it took to save caches
self.metrics.block_validation.cache_saving_duration.set(elapsed.as_secs_f64());
}

let executed: ExecutedBlockWithTrieUpdates<N> = ExecutedBlockWithTrieUpdates {
Expand Down
Loading