From ab4d299fdee2473a6ce3e35036bbe1cd262607cd Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Fri, 1 May 2026 10:21:38 -0400 Subject: [PATCH] refactor(workflow): compute snapshot stats inside the blocking task write_snapshot_blocking now derives entry_count and bytes from the entries slice instead of taking them as parameters. The arity drops from five to three, and the cheap O(n) work moves off the async runtime into spawn_blocking where the rest of the snapshot already runs. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/crates/fabro-workflow/src/run_metadata.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/crates/fabro-workflow/src/run_metadata.rs b/lib/crates/fabro-workflow/src/run_metadata.rs index 472a0ba85..f86a53b41 100644 --- a/lib/crates/fabro-workflow/src/run_metadata.rs +++ b/lib/crates/fabro-workflow/src/run_metadata.rs @@ -192,14 +192,12 @@ impl RunMetadataWriterHandle { let entries = dump .git_entries() .map_err(RunMetadataError::DumpSerialize)?; - let entry_count = entries.len(); - let bytes = metadata_entries_bytes(&entries); let message = message.to_string(); let writer = Arc::clone(&self.writer); task::spawn_blocking(move || { let mut guard = writer.lock().expect("metadata writer mutex poisoned"); - guard.write_snapshot_blocking(&entries, entry_count, bytes, &message, token.as_deref()) + guard.write_snapshot_blocking(&entries, &message, token.as_deref()) }) .await .map_err(RunMetadataError::Join)? @@ -305,12 +303,12 @@ impl RunMetadataWriter { fn write_snapshot_blocking( &mut self, entries: &[(String, Vec)], - entry_count: usize, - bytes: u64, message: &str, token: Option<&str>, ) -> Result { self.discover_parent(token)?; + let entry_count = entries.len(); + let bytes = metadata_entries_bytes(entries); for (path, _) in entries { validate_metadata_path(path)?; }