chore: add pretty printing for pruned segment info (#12710)

This commit is contained in:
Jun Song
2024-11-21 19:22:42 +09:00
committed by GitHub
parent 1b874dcc6c
commit b9169399f3
2 changed files with 12 additions and 4 deletions

View File

@ -307,7 +307,11 @@ impl NodeState {
info!(tip_block_number, "Pruner started");
}
PrunerEvent::Finished { tip_block_number, elapsed, stats } => {
info!(tip_block_number, ?elapsed, ?stats, "Pruner finished");
let stats = format!(
"[{}]",
stats.iter().map(|item| item.to_string()).collect::<Vec<_>>().join(", ")
);
info!(tip_block_number, ?elapsed, %stats, "Pruner finished");
}
}
}

View File

@ -1,5 +1,6 @@
use crate::{PruneCheckpoint, PruneLimiter, PruneMode, PruneSegment};
use alloy_primitives::{BlockNumber, TxNumber};
use derive_more::Display;
/// Pruner run output.
#[derive(Debug)]
@ -17,7 +18,8 @@ impl From<PruneProgress> for PrunerOutput {
}
/// Represents information of a pruner run for a segment.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Display)]
#[display("(table={segment}, pruned={pruned}, status={progress})")]
pub struct PrunedSegmentInfo {
/// The pruned segment
pub segment: PruneSegment,
@ -77,16 +79,18 @@ impl SegmentOutputCheckpoint {
}
/// Progress of pruning.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Display)]
pub enum PruneProgress {
/// There is more data to prune.
#[display("HasMoreData({_0})")]
HasMoreData(PruneInterruptReason),
/// Pruning has been finished.
#[display("Finished")]
Finished,
}
/// Reason for interrupting a prune run.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Display)]
pub enum PruneInterruptReason {
/// Prune run timed out.
Timeout,