Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(prune): add pruner log with INFO level #4573

Merged
merged 5 commits into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions crates/prune/src/pruner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use reth_provider::{
BlockReader, DatabaseProviderRW, ProviderFactory, PruneCheckpointReader, PruneCheckpointWriter,
TransactionsProvider,
};
use std::{ops::RangeInclusive, sync::Arc, time::Instant};
use tracing::{debug, error, instrument, trace};
use std::{collections::HashMap, ops::RangeInclusive, sync::Arc, time::Instant};
use tracing::{debug, error, info, instrument, trace};

/// Result of [Pruner::run] execution.
///
Expand Down Expand Up @@ -81,6 +81,8 @@ impl<DB: Database> Pruner<DB> {

let mut done = true;

let mut parts_done = HashMap::new();

if let Some((to_block, prune_mode)) =
self.modes.prune_target_block_receipts(tip_block_number)?
{
Expand All @@ -95,6 +97,7 @@ impl<DB: Database> Pruner<DB> {
let part_start = Instant::now();
let part_done = self.prune_receipts(&provider, to_block, prune_mode)?;
done = done && part_done;
parts_done.insert(PrunePart::Receipts, part_done);
self.metrics
.get_prune_part_metrics(PrunePart::Receipts)
.duration_seconds
Expand All @@ -107,6 +110,7 @@ impl<DB: Database> Pruner<DB> {
let part_start = Instant::now();
let part_done = self.prune_receipts_by_logs(&provider, tip_block_number)?;
done = done && part_done;
parts_done.insert(PrunePart::ContractLogs, part_done);
self.metrics
.get_prune_part_metrics(PrunePart::ContractLogs)
.duration_seconds
Expand All @@ -129,6 +133,7 @@ impl<DB: Database> Pruner<DB> {
let part_start = Instant::now();
let part_done = self.prune_transaction_lookup(&provider, to_block, prune_mode)?;
done = done && part_done;
parts_done.insert(PrunePart::TransactionLookup, part_done);
self.metrics
.get_prune_part_metrics(PrunePart::TransactionLookup)
.duration_seconds
Expand All @@ -155,6 +160,7 @@ impl<DB: Database> Pruner<DB> {
let part_start = Instant::now();
let part_done = self.prune_transaction_senders(&provider, to_block, prune_mode)?;
done = done && part_done;
parts_done.insert(PrunePart::SenderRecovery, part_done);
self.metrics
.get_prune_part_metrics(PrunePart::SenderRecovery)
.duration_seconds
Expand All @@ -181,6 +187,7 @@ impl<DB: Database> Pruner<DB> {
let part_start = Instant::now();
let part_done = self.prune_account_history(&provider, to_block, prune_mode)?;
done = done && part_done;
parts_done.insert(PrunePart::AccountHistory, part_done);
self.metrics
.get_prune_part_metrics(PrunePart::AccountHistory)
.duration_seconds
Expand All @@ -207,6 +214,7 @@ impl<DB: Database> Pruner<DB> {
let part_start = Instant::now();
let part_done = self.prune_storage_history(&provider, to_block, prune_mode)?;
done = done && part_done;
parts_done.insert(PrunePart::StorageHistory, part_done);
self.metrics
.get_prune_part_metrics(PrunePart::StorageHistory)
.duration_seconds
Expand All @@ -225,7 +233,14 @@ impl<DB: Database> Pruner<DB> {
let elapsed = start.elapsed();
self.metrics.duration_seconds.record(elapsed);

trace!(target: "pruner", %tip_block_number, ?elapsed, "Pruner finished");
info!(
target: "pruner",
%tip_block_number,
?elapsed,
%done,
?parts_done,
"Pruner finished"
);
Ok(done)
}

Expand Down
Loading