Skip to content

Commit

Permalink
GC - Log total storage footprint
Browse files Browse the repository at this point in the history
Summary: This diff allows the GC to log the total storage footprint for each run. This allows us to find out the storage footprint changes along with the time easier.

Reviewed By: YousefSalama

Differential Revision: D49864056

fbshipit-source-id: c5a9117f8883e0ac696d3bd9646dc3a0958799e2
  • Loading branch information
Haitao Mei authored and facebook-github-bot committed Oct 3, 2023
1 parent dd6ae66 commit 3902258
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions eden/mononoke/cmds/sqlblob_gc/commands/generation_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ fn print_sizes(sizes: &HashMap<Option<u64>, u64>) {
println!("Generation | Size");
println!("-----------------");

let mut total_size = ByteSize::b(0);
for generation in generations {
let size = ByteSize::b(sizes[generation]);
let generation = match generation {
None => "NULL".to_string(),
Some(g) => g.to_string(),
};
println!("{:>10} | {}", generation, size.to_string_as(true));
total_size += size;
}
println!("Total size: {}", total_size.to_string_as(true));
}

pub async fn run(app: MononokeApp, _args: CommandArgs) -> Result<()> {
Expand All @@ -63,6 +66,7 @@ pub async fn run(app: MononokeApp, _args: CommandArgs) -> Result<()> {
.await?;

let mut size_summary = HashMap::new();
let mut total_size: u64 = 0;
for (shard, sizes) in shard_sizes {
for (generation, (size, chunk_id_count)) in sizes.into_iter() {
let mut sample = scuba_sample_builder.clone();
Expand All @@ -72,8 +76,14 @@ pub async fn run(app: MononokeApp, _args: CommandArgs) -> Result<()> {
sample.add("chunk_id_count", chunk_id_count);
sample.log();
*size_summary.entry(generation).or_insert(0u64) += size;
total_size += size;
}
}
if total_size > 0 {
let mut sample = scuba_sample_builder.clone();
sample.add("storage_total_footprint", total_size);
sample.log();
}

if scuba_sample_builder.is_discard() {
print_sizes(&size_summary);
Expand Down
7 changes: 5 additions & 2 deletions eden/mononoke/tests/integration/test-sqlblob-gc.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Run sqlblob_gc generation size report
Generation | Size
-----------------
2 | 199 B
Total size: 199 B

Run sqlblob_gc generation size report again, just to check mark has not broken it
Run sqlblob_gc mark
Expand All @@ -50,7 +51,9 @@ Run sqlblob_gc generation size report again, just to check mark has not broken i
Generation | Size
-----------------
2 | 199 B
Total size: 199 B

Check the sizes are logged
$ jq -r '.int | [ .shard, .generation, .size, .chunk_id_count ] | @csv' < scuba.json | sort
1,2,199,1
$ jq -r '.int | [ .shard, .generation, .size, .chunk_id_count, .storage_total_footprint ] | @csv' < scuba.json | sort
,,,,199
1,2,199,1,

0 comments on commit 3902258

Please sign in to comment.