diff --git a/crates/static-file/static-file/Cargo.toml b/crates/static-file/static-file/Cargo.toml index 7ea23e0132f..46ceaf9b25c 100644 --- a/crates/static-file/static-file/Cargo.toml +++ b/crates/static-file/static-file/Cargo.toml @@ -15,20 +15,22 @@ workspace = true # reth reth-codecs.workspace = true reth-db-api.workspace = true +reth-metrics.workspace = true +reth-primitives-traits.workspace = true reth-provider.workspace = true -reth-storage-errors.workspace = true -reth-tokio-util.workspace = true reth-prune-types.workspace = true -reth-primitives-traits.workspace = true -reth-static-file-types.workspace = true reth-stages-types.workspace = true +reth-static-file-types.workspace = true +reth-storage-errors.workspace = true +reth-tokio-util.workspace = true alloy-primitives.workspace = true # misc -tracing.workspace = true -rayon.workspace = true +metrics.workspace = true parking_lot = { workspace = true, features = ["send_guard", "arc_lock"] } +rayon.workspace = true +tracing.workspace = true [dev-dependencies] reth-stages = { workspace = true, features = ["test-utils"] } diff --git a/crates/static-file/static-file/src/lib.rs b/crates/static-file/static-file/src/lib.rs index 7288129ca33..2bc3678a967 100644 --- a/crates/static-file/static-file/src/lib.rs +++ b/crates/static-file/static-file/src/lib.rs @@ -8,6 +8,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] +mod metrics; pub mod segments; mod static_file_producer; diff --git a/crates/static-file/static-file/src/metrics.rs b/crates/static-file/static-file/src/metrics.rs new file mode 100644 index 00000000000..82752d9c4ab --- /dev/null +++ b/crates/static-file/static-file/src/metrics.rs @@ -0,0 +1,14 @@ +//! Static file producer metrics. + +use metrics::Histogram; +use reth_metrics::Metrics; + +/// Static file producer metrics. +#[derive(Metrics, Clone)] +#[metrics(scope = "static_file.producer")] +pub(crate) struct StaticFileProducerMetrics { + /// Histogram for the time taken to produce static files for a single segment (in seconds). + pub(crate) segment_production_duration: Histogram, + /// Histogram for the total time taken to produce all static files (in seconds). + pub(crate) total_production_duration: Histogram, +} diff --git a/crates/static-file/static-file/src/static_file_producer.rs b/crates/static-file/static-file/src/static_file_producer.rs index 1894626ef1c..58e426e67f1 100644 --- a/crates/static-file/static-file/src/static_file_producer.rs +++ b/crates/static-file/static-file/src/static_file_producer.rs @@ -1,6 +1,8 @@ //! Support for producing static files. -use crate::{segments, segments::Segment, StaticFileProducerEvent}; +use crate::{ + metrics::StaticFileProducerMetrics, segments, segments::Segment, StaticFileProducerEvent, +}; use alloy_primitives::BlockNumber; use parking_lot::Mutex; use rayon::prelude::*; @@ -67,11 +69,18 @@ pub struct StaticFileProducerInner { /// files. See [`StaticFileProducerInner::get_static_file_targets`]. prune_modes: PruneModes, event_sender: EventSender, + /// Metrics for tracking static file production performance. + metrics: StaticFileProducerMetrics, } impl StaticFileProducerInner { fn new(provider: Provider, prune_modes: PruneModes) -> Self { - Self { provider, prune_modes, event_sender: Default::default() } + Self { + provider, + prune_modes, + event_sender: Default::default(), + metrics: StaticFileProducerMetrics::default(), + } } } @@ -145,7 +154,8 @@ where let provider = self.provider.database_provider_ro()?.disable_long_read_transaction_safety(); segment.copy_to_static_files(provider, block_range.clone())?; - let elapsed = start.elapsed(); // TODO(alexey): track in metrics + let elapsed = start.elapsed(); + self.metrics.segment_production_duration.record(elapsed); debug!(target: "static_file", segment = %segment.segment(), ?block_range, ?elapsed, "Finished StaticFileProducer segment"); Ok(()) @@ -158,7 +168,8 @@ where .update_index(segment.segment(), Some(*block_range.end()))?; } - let elapsed = start.elapsed(); // TODO(alexey): track in metrics + let elapsed = start.elapsed(); + self.metrics.total_production_duration.record(elapsed); debug!(target: "static_file", ?targets, ?elapsed, "StaticFileProducer finished"); self.event_sender diff --git a/deny.toml b/deny.toml index 530b8cf90c3..efca2377282 100644 --- a/deny.toml +++ b/deny.toml @@ -4,14 +4,14 @@ [advisories] yanked = "warn" ignore = [ - # https://rustsec.org/advisories/RUSTSEC-2024-0384 used by sse example - "RUSTSEC-2024-0384", # https://rustsec.org/advisories/RUSTSEC-2024-0436 paste! is unmaintained "RUSTSEC-2024-0436", # https://rustsec.org/advisories/RUSTSEC-2025-0141 bincode is unmaintained, need to transition all deps to wincode first "RUSTSEC-2025-0141", - # https://rustsec.org/advisories/RUSTSEC-2026-0002 lru unused directly: - "RUSTSEC-2026-0002", + # https://rustsec.org/advisories/RUSTSEC-2026-0007 bytes integer overflow, will be fixed in separate PR + "RUSTSEC-2026-0007", + # https://rustsec.org/advisories/RUSTSEC-2026-0009 time DoS vulnerability, will be fixed in separate PR + "RUSTSEC-2026-0009", ] # This section is considered when running `cargo deny check bans`.