perf: skip missed ticks on all intervals, reduce scan frequency
All checks were successful
Build Archipelago ISO (dev) / build-iso (push) Successful in 23m2s
All checks were successful
Build Archipelago ISO (dev) / build-iso (push) Successful in 23m2s
Prevents burst of health checks, scans, and snapshots after slow podman responses by using MissedTickBehavior::Skip. Bumps container scan interval from 30s to 60s to reduce DB lock contention. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -445,6 +445,7 @@ pub fn spawn_snapshot_task(data_dir: PathBuf) {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(120)).await;
|
||||
|
||||
let mut interval = tokio::time::interval(std::time::Duration::from_secs(120));
|
||||
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
||||
loop {
|
||||
interval.tick().await;
|
||||
if let Err(e) = save_container_snapshot(&data_dir).await {
|
||||
|
||||
@@ -487,6 +487,8 @@ pub fn spawn_health_monitor(state: Arc<StateManager>, data_dir: PathBuf) {
|
||||
let mut mem_tracker = MemoryTracker::new();
|
||||
let mut mem_check_counter: u32 = 0;
|
||||
let mut interval = tokio::time::interval(std::time::Duration::from_secs(CHECK_INTERVAL_SECS));
|
||||
// Skip missed ticks — prevents burst of health checks after slow podman response
|
||||
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
||||
|
||||
// Load persistent restart history and seed the in-memory tracker
|
||||
let mut restart_history = RestartHistory::load(&data_dir).await;
|
||||
|
||||
@@ -29,6 +29,7 @@ pub fn spawn_metrics_collector(
|
||||
tokio::time::sleep(std::time::Duration::from_secs(60)).await;
|
||||
|
||||
let mut interval = tokio::time::interval(std::time::Duration::from_secs(300));
|
||||
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
||||
|
||||
loop {
|
||||
interval.tick().await;
|
||||
|
||||
@@ -277,9 +277,12 @@ impl Server {
|
||||
error!("Failed to scan containers: {}", e);
|
||||
}
|
||||
|
||||
// Periodic scan every 30 seconds (only broadcasts if state changed)
|
||||
// Periodic scan every 60 seconds (only broadcasts if state changed)
|
||||
// Uses an in-flight guard to skip scans when a previous one is still running
|
||||
let mut interval = tokio::time::interval(Duration::from_secs(30));
|
||||
let mut interval = tokio::time::interval(Duration::from_secs(60));
|
||||
// Skip missed ticks instead of catching up — prevents burst of scans
|
||||
// after a slow podman response (which causes DB lock storms)
|
||||
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
||||
let scanning = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
loop {
|
||||
interval.tick().await;
|
||||
|
||||
Reference in New Issue
Block a user