Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_honk_rounds.bench.cpp
Go to the documentation of this file.
1#include <benchmark/benchmark.h>
2
9
10using namespace benchmark;
11using namespace bb;
12
13// The rounds to measure
14enum {
22};
23
32BB_PROFILE void test_round_inner(State& state, MegaProver& prover, size_t index) noexcept
33{
34 auto time_if_index = [&](size_t target_index, auto&& func) -> void {
36 if (index == target_index) {
37 state.ResumeTiming();
38 }
39
40 func();
41 if (index == target_index) {
42 state.PauseTiming();
43 } else {
44 // We don't actually want to write to user-defined counters
46 }
47 };
48 // why is this mega if the name of file is ultra
49 auto verification_key = std::make_shared<MegaFlavor::VerificationKey>(prover.proving_key->get_precomputed());
50 OinkProver<MegaFlavor> oink_prover(prover.proving_key, verification_key, prover.transcript);
51 time_if_index(PREAMBLE, [&] { oink_prover.execute_preamble_round(); });
52 time_if_index(WIRE_COMMITMENTS, [&] { oink_prover.execute_wire_commitments_round(); });
53 time_if_index(SORTED_LIST_ACCUMULATOR, [&] { oink_prover.execute_sorted_list_accumulator_round(); });
54 time_if_index(LOG_DERIVATIVE_INVERSE, [&] { oink_prover.execute_log_derivative_inverse_round(); });
55 time_if_index(GRAND_PRODUCT_COMPUTATION, [&] { oink_prover.execute_grand_product_computation_round(); });
56 time_if_index(GENERATE_ALPHAS, [&] { prover.proving_key->alphas = oink_prover.generate_alphas_round(); });
57
58 prover.generate_gate_challenges();
59
60 DeciderProver_<MegaFlavor> decider_prover(prover.proving_key, prover.transcript);
61 time_if_index(RELATION_CHECK, [&] { decider_prover.execute_relation_check_rounds(); });
62}
63BB_PROFILE static void test_round(State& state, size_t index) noexcept
64{
65 auto log2_num_gates = static_cast<size_t>(state.range(0));
67
68 // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits
69 auto prover = bb::mock_circuits::get_prover<MegaProver>(
70 &bb::mock_circuits::generate_basic_arithmetic_circuit<MegaCircuitBuilder>, log2_num_gates);
71 for (auto _ : state) {
72 state.PauseTiming();
73 test_round_inner(state, prover, index);
74 state.ResumeTiming();
75 // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness
76 }
77}
78#define ROUND_BENCHMARK(round) \
79 static void ROUND_##round(State& state) noexcept \
80 { \
81 test_round(state, round); \
82 } \
83 BENCHMARK(ROUND_##round)->DenseRange(12, 19)->Unit(kMillisecond)
84
85// Fast rounds take a long time to benchmark because of how we compute statistical significance.
86// Limit to one iteration so we don't spend a lot of time redoing full proofs just to measure this part.
87ROUND_BENCHMARK(PREAMBLE)->Iterations(1);
94
BB_PROFILE void execute_relation_check_rounds()
Run Sumcheck to establish that ∑_i pow(\vec{β*})f_i(ω) = e*. This results in u = (u_1,...
Class for all the oink rounds, which are shared between the folding prover and ultra prover.
void execute_log_derivative_inverse_round()
Compute log derivative inverse polynomial and its commitment, if required.
void execute_grand_product_computation_round()
Compute permutation and lookup grand product polynomials and their commitments.
void execute_preamble_round()
Add circuit size, public input size, and public inputs to transcript.
SubrelationSeparators generate_alphas_round()
void execute_sorted_list_accumulator_round()
Compute sorted witness-table accumulator and commit to the resulting polynomials.
void execute_wire_commitments_round()
Commit to the wire polynomials (part of the witness), with the exception of the fourth wire,...
#define BB_PROFILE
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define BB_REPORT_OP_COUNT_IN_BENCH(state)
#define BB_REPORT_OP_COUNT_BENCH_CANCEL()
@ SORTED_LIST_ACCUMULATOR
@ GRAND_PRODUCT_COMPUTATION
@ LOG_DERIVATIVE_INVERSE
BENCHMARK_MAIN()
BB_PROFILE void test_round_inner(State &state, MegaProver &prover, size_t index) noexcept
#define ROUND_BENCHMARK(round)