|
| 1 | +#[global_allocator] |
| 2 | +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; |
| 3 | + |
1 | 4 | use anyhow::Error;
|
2 |
| -use binius::bench::{prove, sha256_no_lookup_prepare, verify}; |
| 5 | +use binius::bench::{prove, sha256_no_lookup_prepare, sha256_with_lookup_prepare}; |
| 6 | +use binius_utils::{SerializationMode, SerializeBytes}; |
| 7 | +use jemalloc_ctl::{ |
| 8 | + epoch, |
| 9 | + stats::{self}, |
| 10 | +}; |
3 | 11 |
|
4 | 12 | fn main() -> Result<(), Error> {
|
| 13 | + // No-lookup sha256 |
| 14 | + epoch::advance().unwrap(); |
| 15 | + let resident_before = stats::resident::read().unwrap(); |
| 16 | + |
5 | 17 | let allocator = bumpalo::Bump::new();
|
6 | 18 | let (constraint_system, args, witness, backend) = sha256_no_lookup_prepare(&allocator);
|
7 | 19 |
|
8 |
| - let (cs, args, proof) = prove(constraint_system, args, witness, backend); |
| 20 | + epoch::advance().unwrap(); |
| 21 | + let resident_after = stats::resident::read().unwrap(); |
| 22 | + |
| 23 | + println!( |
| 24 | + "Preprocessing: resident memory (no lookup): {} MB", |
| 25 | + (resident_after - resident_before) as f32 / 1024.0 / 1024.0, |
| 26 | + ); |
| 27 | + |
| 28 | + let mut write_buf = vec![]; |
| 29 | + constraint_system |
| 30 | + .serialize(&mut write_buf, SerializationMode::Native) |
| 31 | + .unwrap(); |
| 32 | + let len = write_buf.len(); |
| 33 | + println!( |
| 34 | + "Constraint system size (no lookup): {} KB", |
| 35 | + len as f32 / 1024.0 |
| 36 | + ); |
| 37 | + |
| 38 | + epoch::advance().unwrap(); |
| 39 | + let resident_before = stats::resident::read().unwrap(); |
| 40 | + |
| 41 | + let (_, _, _) = prove(constraint_system, args, witness, backend); |
| 42 | + |
| 43 | + epoch::advance().unwrap(); |
| 44 | + let resident_after = stats::resident::read().unwrap(); |
| 45 | + println!( |
| 46 | + "Proving: resident memory (no lookup): {} MB", |
| 47 | + (resident_after - resident_before) as f32 / 1024.0 / 1024.0, |
| 48 | + ); |
| 49 | + |
| 50 | + //Lookup sha256 |
| 51 | + epoch::advance().unwrap(); |
| 52 | + let resident_before = stats::resident::read().unwrap(); |
| 53 | + |
| 54 | + let allocator = bumpalo::Bump::new(); |
| 55 | + let (constraint_system, args, witness, backend) = sha256_with_lookup_prepare(&allocator); |
| 56 | + |
| 57 | + epoch::advance().unwrap(); |
| 58 | + let resident_after = stats::resident::read().unwrap(); |
| 59 | + |
| 60 | + println!( |
| 61 | + "Preprocessing: resident memory (with lookup): {} MB", |
| 62 | + (resident_after - resident_before) as f32 / 1024.0 / 1024.0, |
| 63 | + ); |
| 64 | + |
| 65 | + let mut write_buf = vec![]; |
| 66 | + constraint_system |
| 67 | + .serialize(&mut write_buf, SerializationMode::Native) |
| 68 | + .unwrap(); |
| 69 | + let len = write_buf.len(); |
| 70 | + println!( |
| 71 | + "Constraint system size (with lookup): {} KB", |
| 72 | + len as f32 / 1024.0 |
| 73 | + ); |
| 74 | + |
| 75 | + epoch::advance().unwrap(); |
| 76 | + let resident_before = stats::resident::read().unwrap(); |
| 77 | + |
| 78 | + let (_, _, _) = prove(constraint_system, args, witness, backend); |
9 | 79 |
|
10 |
| - verify(cs, args, proof); |
| 80 | + epoch::advance().unwrap(); |
| 81 | + let resident_after = stats::resident::read().unwrap(); |
| 82 | + println!( |
| 83 | + "Proving: resident memory (with lookup): {} MB", |
| 84 | + (resident_after - resident_before) as f32 / 1024.0 / 1024.0, |
| 85 | + ); |
11 | 86 |
|
12 | 87 | Ok(())
|
13 | 88 | }
|
0 commit comments