diff --git a/app/buck2_event_observer/src/re_state.rs b/app/buck2_event_observer/src/re_state.rs index 73e08f46c8c6..fc4ceed26dcf 100644 --- a/app/buck2_event_observer/src/re_state.rs +++ b/app/buck2_event_observer/src/re_state.rs @@ -149,6 +149,27 @@ impl ReState { Ok(Some(Line::unstyled(&line)?)) } + fn render_local_cache_stat( + &self, + name: &str, + hits_files: i64, + hits_bytes: i64, + misses_files: i64, + misses_bytes: i64, + ) -> buck2_error::Result> { + let line = format!( + "{:<20}: \ + {:>5} / {:>5} files hits, \ + {:>5} / {:>5} files misses ", + name, + HumanizedBytes::new(hits_bytes as u64), + hits_files, + HumanizedBytes::new(misses_bytes as u64), + misses_files, + ); + Ok(Some(Line::unstyled(&line)?)) + } + fn render_detailed(&self, two_snapshots: &TwoSnapshots) -> buck2_error::Result> { let mut r = Vec::new(); if let (Some(first), Some((_, last))) = (&self.first_snapshot, &two_snapshots.last) { @@ -199,6 +220,14 @@ impl ReState { "http_download_bytes", last.http_download_bytes - first.http_download_bytes, )?); + + r.extend(self.render_local_cache_stat( + "local_cache", + last.local_cache_hits_files - first.local_cache_hits_files, + last.local_cache_hits_bytes - first.local_cache_hits_bytes, + last.local_cache_misses_files - first.local_cache_misses_files, + last.local_cache_misses_bytes - first.local_cache_misses_bytes, + )?); } Ok(r) }