From 3af7c116d41c06822006fb447211e3792862fd7c Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2026 13:07:48 +0100 Subject: add disk I/O stats --- src/main.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index d6773eb..57c26b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,9 +120,14 @@ async fn main() -> Result<()> { Some(path) => Some(bootstrap::load_backup(path)?), None => None, }; - let (initial_doc, recovered_epoch, recovered_swarm) = match recovered { - Some((doc, epoch, swarm_id)) => (doc, Some(epoch), Some(swarm_id)), - None => (AutoCommit::new(), None, None), + let (initial_doc, recovered_epoch, recovered_swarm, backup_bytes) = match recovered { + Some(backup) => ( + backup.doc, + Some(backup.epoch), + Some(backup.swarm_id), + Some(backup.bytes), + ), + None => (AutoCommit::new(), None, None, None), }; let initial_epoch = match (recovered_epoch, args.debug_epoch) { (Some(epoch), _) => epoch, @@ -188,6 +193,14 @@ async fn main() -> Result<()> { trace!("Application state initialized"); + // Files read before the state existed. + let read = backup_bytes + .into_iter() + .chain(state.state_file.as_ref().and_then(|file| file.read_bytes())); + for bytes in read { + state.stats.disk_read(bytes); + } + // Join the remembered swarm and no other; HELLOs claim it. A backup to recover from // names its swarm itself, which wins. let start = match recovered_swarm { -- cgit v1.3.1