Skip to content

Commit

Permalink
add local cache stats to superconsole
Browse files Browse the repository at this point in the history
Summary: Display local cache stats in detailed RE section

Reviewed By: manicaesar

Differential Revision: D65946701

fbshipit-source-id: 21e326d10895d1ccf681d1a0ae0d7af93ad1f96d
  • Loading branch information
Yury Samkevich authored and facebook-github-bot committed Nov 15, 2024
1 parent 99d2dcb commit d7c4e94
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/buck2_event_observer/src/re_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<Line>> {
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<Vec<Line>> {
let mut r = Vec::new();
if let (Some(first), Some((_, last))) = (&self.first_snapshot, &two_snapshots.last) {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit d7c4e94

Please sign in to comment.