Add a pagectl tool to recompress image layers

This commit is contained in:
Arpad Müller
2024-05-24 03:00:06 +02:00
parent 6c6a7f9ace
commit 8745c0d6f2
8 changed files with 226 additions and 18 deletions

View File

@@ -55,6 +55,10 @@ pub(crate) enum LayerCmd {
#[clap(long)]
new_timeline_id: Option<TimelineId>,
},
Compress {
dest_path: Utf8PathBuf,
layer_file_path: Utf8PathBuf,
},
}
async fn read_delta_file(path: impl AsRef<Path>, ctx: &RequestContext) -> Result<()> {
@@ -240,5 +244,22 @@ pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> {
anyhow::bail!("not an image or delta layer: {layer_file_path}");
}
LayerCmd::Compress {
dest_path,
layer_file_path,
} => {
pageserver::virtual_file::init(10, virtual_file::api::IoEngineKind::StdFs);
pageserver::page_cache::init(100);
let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error);
let stats =
ImageLayer::compression_statistics(dest_path, layer_file_path, &ctx).await?;
println!(
"Statistics: {stats:#?}\n{}",
serde_json::to_string(&stats).unwrap()
);
return Ok(());
}
}
}