-
Notifications
You must be signed in to change notification settings - Fork 3
feat: unify the metrics across the repo(0) #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fbbd4f9
chore: git ignore "*.csv" files
guorong009 1d36937
feat: add "CustomMetrics" to "utils"
guorong009 0dd0feb
feat: use CustomMetrics for binius benchmarks
guorong009 4a9a46f
feat: use CustomMetrics for plonky2 benchmark
guorong009 fcf5634
feat: use CustomMetrics for plonky3-powdr benchmark
guorong009 9c0c010
feat: use CustomMetrics for plonky3-sp1 benchmark
guorong009 e974053
Merge branch 'CSP-Q3-2025' into unify-metrics
guorong009 9e1c8ee
chore: git ignore "*.json" files
guorong009 91630e4
feat: update "CustomMetrics" as "SubMetrics"
guorong009 fa3f704
feat: use SubMetrics for benchmarks
guorong009 95d80a4
chore: cargo fmt
guorong009 f3c4032
fix: compute "preprocessing_size" for plonky2 and plonky3-powdr
guorong009 ae7b580
fix: compute "preprocessing_size" in binius benchmarks
guorong009 d322b0b
chore: add comments for "preprocessing_size" computation
guorong009 17347e0
fix: correct the "preprocessing_size" computations
guorong009 92ff67b
fix: roll back change in plonky2 preprocessing_size computation
guorong009 eef50ab
fix: add PIL file size to "preprocessing_size" in plonky3-powdr
guorong009 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ dist/ | |
Dockerfile | ||
rust-project.json | ||
tmp/ | ||
*.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
use anyhow::Error; | ||
use binius::bench::{prove, sha256_with_lookup_prepare, verify}; | ||
use utils::bench::measure_peak_memory; | ||
use binius::bench::{prove, sha256_with_lookup_prepare}; | ||
use binius_utils::SerializeBytes; | ||
use utils::bench::{SubMetrics, measure_peak_memory, write_json_submetrics}; | ||
|
||
fn main() -> Result<(), Error> { | ||
let json_file = "sha2_binius_lookup_submetrics.json"; | ||
|
||
let input_num_bytes = 2048; | ||
let metrics = benchmark_sha2(input_num_bytes)?; | ||
|
||
write_json_submetrics(json_file, &metrics); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn benchmark_sha2(num_bytes: usize) -> Result<SubMetrics, Error> { | ||
let mut metrics = SubMetrics::new(num_bytes); | ||
|
||
let allocator = bumpalo::Bump::new(); | ||
|
||
let ((constraint_system, args, witness, backend), peak_memory) = | ||
measure_peak_memory(|| sha256_with_lookup_prepare(&allocator)); | ||
metrics.preprocessing_peak_memory = peak_memory; | ||
|
||
println!( | ||
"Preprocessing(lookup) peak memory: {} MB", | ||
peak_memory as f32 / (1024.0 * 1024.0), | ||
); | ||
let mut buffer: Vec<u8> = Vec::new(); | ||
let _ = constraint_system | ||
.serialize(&mut buffer, binius_utils::SerializationMode::CanonicalTower) | ||
.expect("Failed to serialize constraint system"); | ||
metrics.preprocessing_size = buffer.len(); // correct? | ||
|
||
let ((cs, args, proof), peak_memory) = | ||
let ((_, _, proof), peak_memory) = | ||
measure_peak_memory(|| prove(constraint_system, args, witness, backend)); | ||
metrics.proving_peak_memory = peak_memory; | ||
metrics.proof_size = proof.get_proof_size(); | ||
|
||
println!( | ||
"Proving(lookup) peak memory: {} MB", | ||
peak_memory as f32 / (1024.0 * 1024.0) | ||
); | ||
|
||
verify(cs, args, proof); | ||
|
||
Ok(()) | ||
Ok(metrics) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
use anyhow::Error; | ||
use binius::bench::{prove, sha256_no_lookup_prepare, verify}; | ||
use utils::bench::measure_peak_memory; | ||
use binius::bench::{prove, sha256_no_lookup_prepare}; | ||
use binius_utils::SerializeBytes; | ||
use utils::bench::{SubMetrics, measure_peak_memory, write_json_submetrics}; | ||
|
||
fn main() -> Result<(), Error> { | ||
let json_file = "sha2_binius_no_lookup_submetrics.json"; | ||
|
||
let input_num_bytes = 2048; | ||
let metrics = benchmark_sha2(input_num_bytes)?; | ||
|
||
write_json_submetrics(json_file, &metrics); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn benchmark_sha2(num_bytes: usize) -> Result<SubMetrics, Error> { | ||
let mut metrics = SubMetrics::new(num_bytes); | ||
|
||
let allocator = bumpalo::Bump::new(); | ||
|
||
let ((constraint_system, args, witness, backend), peak_memory) = | ||
measure_peak_memory(|| sha256_no_lookup_prepare(&allocator)); | ||
metrics.preprocessing_peak_memory = peak_memory; | ||
|
||
println!( | ||
"Preprocessing(no lookup) peak memory: {} MB", | ||
peak_memory as f32 / (1024.0 * 1024.0), | ||
); | ||
let mut buffer: Vec<u8> = Vec::new(); | ||
let _ = constraint_system | ||
.serialize(&mut buffer, binius_utils::SerializationMode::CanonicalTower) | ||
.expect("Failed to serialize constraint system"); | ||
metrics.preprocessing_size = buffer.len(); // correct? | ||
guorong009 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
let ((cs, args, proof), peak_memory) = | ||
let ((_, _, proof), peak_memory) = | ||
measure_peak_memory(|| prove(constraint_system, args, witness, backend)); | ||
metrics.proving_peak_memory = peak_memory; | ||
metrics.proof_size = proof.get_proof_size(); | ||
|
||
println!( | ||
"Proving(no lookup) peak memory: {} MB", | ||
peak_memory as f32 / (1024.0 * 1024.0) | ||
); | ||
|
||
verify(cs, args, proof); | ||
|
||
Ok(()) | ||
Ok(metrics) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
use sha::bench::{prepare_pipeline, prove, verify}; | ||
use utils::bench::measure_peak_memory; | ||
use sha::bench::{prepare_pipeline, prove}; | ||
use utils::bench::{SubMetrics, measure_peak_memory, write_json_submetrics}; | ||
|
||
fn main() { | ||
let (mut pipeline, peak_memory) = measure_peak_memory(prepare_pipeline); | ||
let json_file = "sha2_plonky3_powdr_submetrics.json"; | ||
|
||
let input_num_bytes = 2048; | ||
let metrics = benchmark_sha2(input_num_bytes); | ||
|
||
write_json_submetrics(json_file, &metrics); | ||
} | ||
|
||
fn benchmark_sha2(num_bytes: usize) -> SubMetrics { | ||
let mut metrics = SubMetrics::new(num_bytes); | ||
|
||
let (mut pipeline, peak_memory) = measure_peak_memory(|| prepare_pipeline()); | ||
metrics.preprocessing_peak_memory = peak_memory; | ||
println!( | ||
"Preprocessing peak memory: {} GB", | ||
peak_memory as f32 / (1024.0 * 1024.0 * 1024.0), | ||
); | ||
|
||
// Load the proving key and constants from the files. | ||
let pk_bytes = std::fs::read("powdr-target/pkey.bin").expect("Unable to read file"); | ||
let constants_bytes = std::fs::read("powdr-target/constants.bin").expect("Unable to read file"); | ||
metrics.preprocessing_size = pk_bytes.len() + constants_bytes.len(); // correct? | ||
|
||
let (_, peak_memory) = measure_peak_memory(|| prove(&mut pipeline)); | ||
metrics.proving_peak_memory = peak_memory; | ||
metrics.proof_size = pipeline.proof().unwrap().len(); | ||
|
||
println!( | ||
"Proving peak memory: {} GB", | ||
peak_memory as f32 / (1024.0 * 1024.0 * 1024.0), | ||
); | ||
|
||
verify(pipeline); | ||
metrics | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.