mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
Histogram support in runtime metrics (#6935)
* Histogram support in runtime metrics Add support for histograms to the runtime metrics. Additionally add `polkadot_parachain_verify_dispute_signature` histogram which tracks the time needed from the runtime to verify a single validator signature of a dispute statement. * Add noops * u64 instead of f64 * Update buckets * Wrap `get_current_time()` in runtime metrics * Change the dimension of the Histogram from usec to sec * Fix a compilation error * Update buckets * Fix `on_signature_check_complete` calculation * Update buckets * Update buckets * formatting * Another weights update * Adjust buckets again * Final buckets adjustment * Revert "Fix a compilation error" This reverts commit 06290b40a39eeb78de2602d8916a39edf7a8b714. * Update primitives/src/v4/metrics.rs Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com> * Use `saturating_sub` for time difference calculation * Pass nanoseconds to client instead of seconds (using f64 in runtime is dangerous) --------- Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4903859544
commit
22f404f092
@@ -16,11 +16,14 @@
|
||||
|
||||
//! Runtime component for handling disputes of parachain candidates.
|
||||
|
||||
use crate::{configuration, initializer::SessionChangeNotification, session_info};
|
||||
use crate::{
|
||||
configuration, initializer::SessionChangeNotification, metrics::METRICS, session_info,
|
||||
};
|
||||
use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0};
|
||||
use frame_support::{ensure, weights::Weight};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_runtime_metrics::get_current_time;
|
||||
use primitives::{
|
||||
byzantine_threshold, supermajority_threshold, ApprovalVote, CandidateHash,
|
||||
CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CompactStatement, ConsensusLog,
|
||||
@@ -1336,9 +1339,14 @@ fn check_signature(
|
||||
ExplicitDisputeStatement { valid: false, candidate_hash, session }.signing_payload(),
|
||||
};
|
||||
|
||||
if validator_signature.verify(&payload[..], &validator_public) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
let start = get_current_time();
|
||||
|
||||
let res =
|
||||
if validator_signature.verify(&payload[..], &validator_public) { Ok(()) } else { Err(()) };
|
||||
|
||||
let end = get_current_time();
|
||||
|
||||
METRICS.on_signature_check_complete(end.saturating_sub(start)); // ns
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
//! Runtime declaration of the parachain metrics.
|
||||
|
||||
use polkadot_runtime_metrics::{Counter, CounterVec};
|
||||
use polkadot_runtime_metrics::{Counter, CounterVec, Histogram};
|
||||
use primitives::metric_definitions::{
|
||||
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
|
||||
PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED,
|
||||
PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED,
|
||||
PARACHAIN_INHERENT_DATA_WEIGHT,
|
||||
PARACHAIN_INHERENT_DATA_WEIGHT, PARACHAIN_VERIFY_DISPUTE_SIGNATURE,
|
||||
};
|
||||
|
||||
pub struct Metrics {
|
||||
@@ -37,6 +37,9 @@ pub struct Metrics {
|
||||
disputes_included: Counter,
|
||||
/// Counts bitfield signature checks in `enter_inner`.
|
||||
bitfields_signature_checks: CounterVec,
|
||||
|
||||
/// Histogram with the time spent checking a validator signature of a dispute statement
|
||||
signature_timings: Histogram,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
@@ -98,11 +101,15 @@ impl Metrics {
|
||||
}
|
||||
|
||||
pub fn on_valid_bitfield_signature(&self) {
|
||||
self.bitfields_signature_checks.with_label_values(&["valid"]).inc();
|
||||
self.bitfields_signature_checks.with_label_values(&["valid"]).inc_by(1);
|
||||
}
|
||||
|
||||
pub fn on_invalid_bitfield_signature(&self) {
|
||||
self.bitfields_signature_checks.with_label_values(&["invalid"]).inc();
|
||||
self.bitfields_signature_checks.with_label_values(&["invalid"]).inc_by(1);
|
||||
}
|
||||
|
||||
pub fn on_signature_check_complete(&self, val: u128) {
|
||||
self.signature_timings.observe(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,4 +122,5 @@ pub const METRICS: Metrics = Metrics {
|
||||
bitfields_signature_checks: CounterVec::new(
|
||||
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
|
||||
),
|
||||
signature_timings: Histogram::new(PARACHAIN_VERIFY_DISPUTE_SIGNATURE),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user