From e0ed7e862c8c8b6c75eda1731c449543642176ef Mon Sep 17 00:00:00 2001 From: Andrei Sandu <54316454+sandreim@users.noreply.github.com> Date: Thu, 20 Jul 2023 10:40:47 +0300 Subject: [PATCH] uncompressed pov metrics (#7524) Signed-off-by: Andrei Sandu --- node/core/candidate-validation/src/lib.rs | 3 ++- node/core/candidate-validation/src/metrics.rs | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/node/core/candidate-validation/src/lib.rs b/node/core/candidate-validation/src/lib.rs index b2aa0fd15105..b3055afd5772 100644 --- a/node/core/candidate-validation/src/lib.rs +++ b/node/core/candidate-validation/src/lib.rs @@ -590,6 +590,7 @@ where }; metrics.observe_code_size(raw_validation_code.len()); + metrics.observe_pov_size(pov.block_data.0.len(), true); let raw_block_data = match sp_maybe_compressed_blob::decompress(&pov.block_data.0, POV_BOMB_LIMIT) { Ok(block_data) => BlockData(block_data.to_vec()), @@ -600,7 +601,7 @@ where return Ok(ValidationResult::Invalid(InvalidCandidate::PoVDecompressionFailure)) }, }; - metrics.observe_pov_size(raw_block_data.0.len()); + metrics.observe_pov_size(raw_block_data.0.len(), false); let params = ValidationParams { parent_head: persisted_validation_data.parent_head.clone(), diff --git a/node/core/candidate-validation/src/metrics.rs b/node/core/candidate-validation/src/metrics.rs index 025e5413e72c..28fc957ddb1a 100644 --- a/node/core/candidate-validation/src/metrics.rs +++ b/node/core/candidate-validation/src/metrics.rs @@ -23,7 +23,7 @@ pub(crate) struct MetricsInner { pub(crate) validate_from_chain_state: prometheus::Histogram, pub(crate) validate_from_exhaustive: prometheus::Histogram, pub(crate) validate_candidate_exhaustive: prometheus::Histogram, - pub(crate) pov_size: prometheus::Histogram, + pub(crate) pov_size: prometheus::HistogramVec, pub(crate) code_size: prometheus::Histogram, } @@ -77,9 +77,12 @@ impl Metrics { } } - pub fn observe_pov_size(&self, pov_size: usize) { + pub fn observe_pov_size(&self, pov_size: usize, compressed: bool) { if let Some(metrics) = &self.0 { - metrics.pov_size.observe(pov_size as f64); + metrics + .pov_size + .with_label_values(&[if compressed { "true" } else { "false" }]) + .observe(pov_size as f64); } } } @@ -119,15 +122,16 @@ impl metrics::Metrics for Metrics { registry, )?, pov_size: prometheus::register( - prometheus::Histogram::with_opts( + prometheus::HistogramVec::new( prometheus::HistogramOpts::new( "polkadot_parachain_candidate_validation_pov_size", - "The size of the decompressed proof of validity of a candidate", + "The compressed and decompressed size of the proof of validity of a candidate", ) .buckets( prometheus::exponential_buckets(16384.0, 2.0, 10) .expect("arguments are always valid; qed"), ), + &["compressed"], )?, registry, )?,