From d00e29a27bed0c50fc98d743979948c431ec9345 Mon Sep 17 00:00:00 2001 From: Wen <113942165+wen-coding@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:51:54 -0800 Subject: [PATCH] Only write logs and snapshot if progress changed. --- wen-restart/src/wen_restart.rs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/wen-restart/src/wen_restart.rs b/wen-restart/src/wen_restart.rs index 9296ba8e82bd42..6fba02e91a1685 100644 --- a/wen-restart/src/wen_restart.rs +++ b/wen-restart/src/wen_restart.rs @@ -266,6 +266,7 @@ pub(crate) fn aggregate_restart_last_voted_fork_slots( } let mut cursor = solana_gossip::crds::Cursor::default(); let mut is_full_slots = HashSet::new(); + let mut old_progress = WenRestartProgress::default(); loop { if exit.load(Ordering::Relaxed) { return Err(WenRestartError::Exiting.into()); @@ -322,10 +323,14 @@ pub(crate) fn aggregate_restart_last_voted_fork_slots( .collect(); } filtered_slots.sort(); - info!( - "Active peers: {} Slots to repair: {:?}", - active_percent, &filtered_slots - ); + if progress != &old_progress { + info!( + "Active peers: {} Slots to repair: {:?}", + active_percent, &filtered_slots + ); + write_wen_restart_records(wen_restart_path, progress)?; + old_progress = progress.clone(); + } if filtered_slots.is_empty() && active_percent >= wait_for_supermajority_threshold_percent as f64 { @@ -335,7 +340,6 @@ pub(crate) fn aggregate_restart_last_voted_fork_slots( { *wen_restart_repair_slots.write().unwrap() = filtered_slots; } - write_wen_restart_records(wen_restart_path, progress)?; let elapsed = timestamp().saturating_sub(start); let time_left = GOSSIP_SLEEP_MILLIS.saturating_sub(elapsed); if time_left > 0 { @@ -705,6 +709,7 @@ pub(crate) fn aggregate_restart_heaviest_fork( let mut cursor = solana_gossip::crds::Cursor::default(); let mut total_active_stake = 0; let mut stat_printed_at = Instant::now(); + let mut old_progress = WenRestartProgress::default(); loop { if exit.load(Ordering::Relaxed) { return Ok(()); @@ -747,12 +752,15 @@ pub(crate) fn aggregate_restart_heaviest_fork( .unwrap() .total_active_stake = current_total_active_stake; } - info!( - "Total active stake: {} Total stake {}", - heaviest_fork_aggregate.total_active_stake(), - total_stake - ); - write_wen_restart_records(wen_restart_path, progress)?; + if old_progress != *progress { + info!( + "Total active stake: {} Total stake {}", + heaviest_fork_aggregate.total_active_stake(), + total_stake + ); + write_wen_restart_records(wen_restart_path, progress)?; + old_progress = progress.clone(); + } let elapsed = timestamp().saturating_sub(start); let time_left = GOSSIP_SLEEP_MILLIS.saturating_sub(elapsed); if time_left > 0 {