Skip to content

Commit

Permalink
better metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Jan 30, 2025
1 parent a640505 commit 7c60ae7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
25 changes: 15 additions & 10 deletions crates/engine/tree/src/tree/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,10 @@ where
struct StateRootTaskMetrics {
/// Histogram of proof calculation durations.
pub proof_calculation_duration_histogram: Histogram,
/// Histogram of proof calculation account targets.
pub proof_calculation_account_targets_histogram: Histogram,
/// Histogram of proof calculation storage targets.
pub proof_calculation_storage_targets_histogram: Histogram,
/// Histogram of proof calculation targets with a ccounts.
pub proof_calculation_with_account_targets_histogram: Histogram,
/// Histogram of proof calculation targets with only storage slots.
pub proof_calculation_only_storage_targets_histogram: Histogram,

/// Histogram of sparse trie update durations.
pub sparse_trie_update_duration_histogram: Histogram,
Expand Down Expand Up @@ -689,16 +689,21 @@ where
self.metrics
.proof_calculation_duration_histogram
.record(proof_calculated.elapsed);
self.metrics
.proof_calculation_account_targets_histogram
.record(proof_calculated.update.targets.len() as f64);
self.metrics.proof_calculation_storage_targets_histogram.record(
self.metrics.proof_calculation_with_account_targets_histogram.record(
proof_calculated
.update
.targets
.values()
.filter(|slots| slots.is_with_account())
.count() as f64,
);
self.metrics.proof_calculation_only_storage_targets_histogram.record(
proof_calculated
.update
.targets
.values()
.map(|targets| targets.len() as f64)
.sum::<f64>(),
.filter(|slots| slots.is_only_storage())
.count() as f64,
);

debug!(
Expand Down
4 changes: 4 additions & 0 deletions crates/trie/common/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ impl MultiProofAccountTarget {
matches!(self, Self::WithAccount(_))
}

pub const fn is_only_storage(&self) -> bool {
matches!(self, Self::OnlyStorage(_))
}

pub fn is_empty(&self) -> bool {
match self {
Self::WithAccount(set) | Self::OnlyStorage(set) => set.is_empty(),
Expand Down
4 changes: 2 additions & 2 deletions crates/trie/parallel/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ where
B256HashMap<B256HashSet>,
B256HashMap<B256HashSet>,
) = targets.into_iter().partition_map(|(key, target)| match target {
MultiProofAccountTarget::WithAccount(hash_set) => Either::Left((key, hash_set)),
MultiProofAccountTarget::OnlyStorage(hash_set) => Either::Right((key, hash_set)),
MultiProofAccountTarget::WithAccount(slots) => Either::Left((key, slots)),
MultiProofAccountTarget::OnlyStorage(slots) => Either::Right((key, slots)),
});

// Extend prefix sets with targets
Expand Down

0 comments on commit 7c60ae7

Please sign in to comment.