Kimchi is based on PlonK, a zk-SNARK protocol.
To bench kimchi, we have two types of benchmark engines.
Criterion is used to benchmark time. If you have installed cargo-criterion and gnuplot, you can run the benchmarks via
$ cargo criterion -p kimchi --bench proof_criterion
The result will appear in target/criterion/single\ proof/report/index.html
and
look like this:
Note that it only does 10 passes. To have more accurate statistics, remove the
.sample_size(10)
line from the bench.
The other benchmark uses iai to perform precise one-shot benchmarking. This is useful in CI, for example, where typical benchmarks are affected by the load of the host running CI.
$ cargo bench -p kimchi --bench proof_iai
It will look like this:
bench_proof_creation Instructions: 22045968746 L1 Accesses: 27210681906 L2 Accesses: 32019515 RAM Accesses: 3034134 Estimated Cycles: 27476974171
To obtain a flamegraph:
- install required dependencies based on your OS
- install cargo-flamegraph:
$ cargo install flamegraph
- run cargo flamegraph with
sudo
(or with the option--root
on mac):the binary will run forever, so you have to C-c to exit and produce the$ # flamegraph of the proof creation: $ CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --bin flamegraph --notes "proof creation" -- prove $ # flamegraph of the proof verification: $ CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --bin flamegraph --notes "proof verification" -- verify
flamegraph.svg
file.
Note: lots of good advice on system performance in the flamegraph repo.