From eefb57f2c035be1a398f630dd8cfed8b4ccbe348 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Wed, 30 Apr 2025 17:25:15 +0300 Subject: feat(zkvms_guest_io): Output proof size In each zkVM we'll write the size to /tmp/proof_size and then guest_io will read that value and place it inside our metrics output. This is not the most elegant, and in certain zkVMs the file output is a part of the benchmark timing, but it will have to do. --- zkvms_host_io/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'zkvms_host_io/src/lib.rs') diff --git a/zkvms_host_io/src/lib.rs b/zkvms_host_io/src/lib.rs index ee66bae..a3249a0 100644 --- a/zkvms_host_io/src/lib.rs +++ b/zkvms_host_io/src/lib.rs @@ -21,6 +21,7 @@ static DEFAULT_PUBLIC_INPUT: &str = static DEFAULT_PRIVATE_INPUT: &str = include_str!(concat!(env!("INPUTS_DIR"), "/default_private_input.toml")); static DEFAULT_ENV: &str = include_str!(concat!(env!("INPUTS_DIR"), "/default.env")); +static PROOF_SIZE_FILE_PATH: &str = "/tmp/proof_size"; /// A CLI tool for running and benchmarking guest programs inside a zkVM /// environment. @@ -153,6 +154,14 @@ pub fn read_args() -> RunWith { } } +pub fn output_proof_size(proof: &T) { + output_proof_size_raw(std::mem::size_of_val(proof)); +} + +pub fn output_proof_size_raw(size: usize) { + std::fs::write(PROOF_SIZE_FILE_PATH, size.to_string()).expect(&format!("Couldn't write proof size to \"{PROOF_SIZE_FILE_PATH}\"!")); +} + fn mean(xs: &Vec) -> f32 { if xs.len() == 1 { xs[0] -- cgit v1.2.3