-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into aztec-packages
* master: feat: implement `Eq` trait on `BoundedVec` (#4830) chore: add benchmarks for serializing a dummy program (#4813) chore: remove unnecessary casts in `BoundedVec` (#4831) fix: issue 4682 and add solver for unconstrained bigintegers (#4729) chore(docs): fix wrong Nargo.toml workspace examples (#4822) chore: delete unnecessary Prover.toml file (#4829) chore: fix alerts on rust msrv (#4817) chore(ci): fix alerts on msrv issues (#4816) chore: run clippy (#4810) chore: optimize poseidon2 implementation (#4807) fix: catch panics from EC point creation (e.g. the point is at infinity) (#4790)
- Loading branch information
Showing
9 changed files
with
232 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; | ||
use std::{collections::BTreeSet, time::Duration}; | ||
|
||
use acir::{ | ||
circuit::{Circuit, ExpressionWidth, Opcode, Program, PublicInputs}, | ||
native_types::{Expression, Witness}, | ||
FieldElement, | ||
}; | ||
|
||
use pprof::criterion::{Output, PProfProfiler}; | ||
|
||
const SIZES: [usize; 9] = [10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000]; | ||
|
||
fn sample_program(num_opcodes: usize) -> Program { | ||
let assert_zero_opcodes: Vec<Opcode> = (0..num_opcodes) | ||
.map(|i| { | ||
Opcode::AssertZero(Expression { | ||
mul_terms: vec![( | ||
FieldElement::from(2 * i), | ||
Witness(i as u32), | ||
Witness(i as u32 + 10), | ||
)], | ||
linear_combinations: vec![ | ||
(FieldElement::from(2 * i), Witness(i as u32)), | ||
(FieldElement::from(3 * i), Witness(i as u32 + 1)), | ||
], | ||
q_c: FieldElement::from(i), | ||
}) | ||
}) | ||
.collect(); | ||
|
||
Program { | ||
functions: vec![Circuit { | ||
current_witness_index: 4000, | ||
opcodes: assert_zero_opcodes.to_vec(), | ||
expression_width: ExpressionWidth::Bounded { width: 3 }, | ||
private_parameters: BTreeSet::from([Witness(1), Witness(2), Witness(3), Witness(4)]), | ||
public_parameters: PublicInputs(BTreeSet::from([Witness(5)])), | ||
return_values: PublicInputs(BTreeSet::from([Witness(6)])), | ||
assert_messages: Vec::new(), | ||
recursive: false, | ||
}], | ||
} | ||
} | ||
|
||
fn bench_serialization(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("serialize_program"); | ||
for size in SIZES.iter() { | ||
let program = sample_program(*size); | ||
|
||
group.throughput(Throughput::Elements(*size as u64)); | ||
group.bench_with_input(BenchmarkId::from_parameter(size), &program, |b, program| { | ||
b.iter(|| Program::serialize_program(program)); | ||
}); | ||
} | ||
group.finish(); | ||
|
||
let mut group = c.benchmark_group("serialize_program_json"); | ||
for size in SIZES.iter() { | ||
let program = sample_program(*size); | ||
|
||
group.throughput(Throughput::Elements(*size as u64)); | ||
group.bench_with_input(BenchmarkId::from_parameter(size), &program, |b, program| { | ||
b.iter(|| { | ||
let mut bytes = Vec::new(); | ||
let mut serializer = serde_json::Serializer::new(&mut bytes); | ||
Program::serialize_program_base64(program, &mut serializer) | ||
}); | ||
}); | ||
} | ||
group.finish(); | ||
} | ||
|
||
fn bench_deserialization(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("deserialize_program"); | ||
for size in SIZES.iter() { | ||
let program = sample_program(*size); | ||
let serialized_program = Program::serialize_program(&program); | ||
|
||
group.throughput(Throughput::Elements(*size as u64)); | ||
group.bench_with_input( | ||
BenchmarkId::from_parameter(size), | ||
&serialized_program, | ||
|b, program| { | ||
b.iter(|| Program::deserialize_program(program)); | ||
}, | ||
); | ||
} | ||
group.finish(); | ||
|
||
let mut group = c.benchmark_group("deserialize_program_json"); | ||
for size in SIZES.iter() { | ||
let program = sample_program(*size); | ||
|
||
let serialized_program = { | ||
let mut bytes = Vec::new(); | ||
let mut serializer = serde_json::Serializer::new(&mut bytes); | ||
Program::serialize_program_base64(&program, &mut serializer).expect("should succeed"); | ||
bytes | ||
}; | ||
|
||
group.throughput(Throughput::Elements(*size as u64)); | ||
group.bench_with_input( | ||
BenchmarkId::from_parameter(size), | ||
&serialized_program, | ||
|b, program| { | ||
b.iter(|| { | ||
let mut deserializer = serde_json::Deserializer::from_slice(program); | ||
Program::deserialize_program_base64(&mut deserializer) | ||
}); | ||
}, | ||
); | ||
} | ||
group.finish(); | ||
} | ||
|
||
criterion_group!( | ||
name = benches; | ||
config = Criterion::default().sample_size(40).measurement_time(Duration::from_secs(20)).with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); | ||
targets = bench_serialization, bench_deserialization | ||
); | ||
|
||
criterion_main!(benches); |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid |
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
echo 4 | sudo tee /proc/sys/kernel/perf_event_paranoid |
1 change: 0 additions & 1 deletion
1
test_programs/execution_success/fold_after_inlined_calls/Prover.toml
This file was deleted.
Oops, something went wrong.
This file contains 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