From 607911ad9312ee520c17e1ad95a2a586e67f7003 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 18 Oct 2023 01:06:02 +0000 Subject: [PATCH 1/8] feat: widget benchmarking --- .../src/barretenberg/benchmark/CMakeLists.txt | 2 +- .../benchmark/honk_bench/CMakeLists.txt | 6 +-- .../benchmark/relations_bench/CMakeLists.txt | 7 ++- .../relations_bench/widget.bench.cpp | 44 +++++++++++++++++++ 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp diff --git a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt index d851d5af285..16f375379bb 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt @@ -2,4 +2,4 @@ add_subdirectory(decrypt_bench) add_subdirectory(pippenger_bench) add_subdirectory(plonk_bench) add_subdirectory(honk_bench) -add_subdirectory(relations_bench) +add_subdirectory(relations_bench) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index 38b08abcb34..fad8d9f141d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -1,8 +1,8 @@ # Each source represents a separate benchmark suite set(BENCHMARK_SOURCES -standard_plonk.bench.cpp -ultra_honk.bench.cpp -ultra_plonk.bench.cpp + standard_plonk.bench.cpp + ultra_honk.bench.cpp + ultra_plonk.bench.cpp ) # Required libraries for benchmark suites diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt index d6b5a9a0df3..0db876053fb 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt @@ -1,7 +1,8 @@ # Each source represents a separate benchmark suite set(BENCHMARK_SOURCES -barycentric.bench.cpp -relations.bench.cpp + barycentric.bench.cpp + relations.bench.cpp + widget.bench.cpp ) # Required libraries for benchmark suites @@ -9,6 +10,8 @@ set(LINKED_LIBRARIES polynomials proof_system benchmark::benchmark + transcript + stdlib_primitives ) # Add executable and custom target for each suite, e.g. ultra_honk_bench diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp new file mode 100644 index 00000000000..92cd704c902 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -0,0 +1,44 @@ +#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" +#include "barretenberg/honk/flavor/goblin_ultra.hpp" +#include "barretenberg/honk/flavor/ultra.hpp" +#include "barretenberg/plonk/composer/ultra_composer.hpp" +#include "barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp" +#include + +namespace { +auto& engine = numeric::random::get_debug_engine(); +} + +namespace proof_system::plonk { + +using FF = barretenberg::fr; + +template void execute_widget(::benchmark::State& state) +{ + // Generate beta and gamma + auto inner_composer = plonk::UltraComposer(); + auto builder = typename plonk::UltraComposer::CircuitBuilder(); + bench_utils::generate_basic_arithmetic_circuit(builder, 1); + auto inner_prover = inner_composer.create_prover(builder); + auto inner_proof = inner_prover.construct_proof(); + auto inner_verifier = inner_composer.create_verifier(builder); + + const size_t num_inner_public_inputs = builder.get_public_inputs().size(); + + transcript::StandardTranscript transcript(inner_proof.proof_data, + plonk::UltraComposer::create_manifest(num_inner_public_inputs), + transcript::HashType::PlookupPedersenBlake3s); + + for (auto _ : state) { + ProverPlookupAuxiliaryWidget value; + value.compute_quotient_contribution(FF::random_element(), transcript); + } +} + +void plookup_auxiliary_widget(::benchmark::State& state) noexcept +{ + execute_widget>(state); +} +BENCHMARK(plookup_auxiliary_widget); + +} // namespace proof_system::plonk From dd146ce1fa4671bff02fb85ec7ae1cf8b1aa72ff Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 18 Oct 2023 01:30:04 +0000 Subject: [PATCH 2/8] fix: use template param --- .../barretenberg/benchmark/relations_bench/widget.bench.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp index 92cd704c902..964386758ba 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -24,13 +24,11 @@ template void execute_widget(::benchmark::Sta auto inner_verifier = inner_composer.create_verifier(builder); const size_t num_inner_public_inputs = builder.get_public_inputs().size(); - transcript::StandardTranscript transcript(inner_proof.proof_data, plonk::UltraComposer::create_manifest(num_inner_public_inputs), transcript::HashType::PlookupPedersenBlake3s); - + Widget value; for (auto _ : state) { - ProverPlookupAuxiliaryWidget value; value.compute_quotient_contribution(FF::random_element(), transcript); } } From a1fc07c520f367dab36b8786e57b92f73cbf4bc3 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 18 Oct 2023 16:48:30 +0000 Subject: [PATCH 3/8] Benchmark fixes --- .../honk_bench/benchmark_utilities.hpp | 3 +++ .../relations_bench/widget.bench.cpp | 19 +++++++------------ .../transition_widgets/transition_widget.hpp | 3 +++ .../barretenberg/transcript/transcript.cpp | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 288f9605c56..242aa86764d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -45,6 +45,9 @@ template void generate_basic_arithmetic_circuit(Builder& buil proof_system::plonk::stdlib::field_t b( proof_system::plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); proof_system::plonk::stdlib::field_t c(&builder); + if (num_gates < 4) { + throw std::runtime_error("too few gates"); + } for (size_t i = 0; i < (num_gates / 4) - 4; ++i) { c = a + b; c = a * c; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp index 964386758ba..d549f7e1281 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -1,6 +1,7 @@ #include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" #include "barretenberg/honk/flavor/goblin_ultra.hpp" #include "barretenberg/honk/flavor/ultra.hpp" +#include "barretenberg/plonk/composer/standard_composer.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp" #include @@ -15,21 +16,15 @@ using FF = barretenberg::fr; template void execute_widget(::benchmark::State& state) { - // Generate beta and gamma - auto inner_composer = plonk::UltraComposer(); - auto builder = typename plonk::UltraComposer::CircuitBuilder(); - bench_utils::generate_basic_arithmetic_circuit(builder, 1); + barretenberg::srs::init_crs_factory("../srs_db/ignition"); + auto inner_composer = plonk::StandardComposer(); + auto builder = typename plonk::StandardComposer::CircuitBuilder(); + bench_utils::generate_basic_arithmetic_circuit(builder, 80); auto inner_prover = inner_composer.create_prover(builder); auto inner_proof = inner_prover.construct_proof(); - auto inner_verifier = inner_composer.create_verifier(builder); - - const size_t num_inner_public_inputs = builder.get_public_inputs().size(); - transcript::StandardTranscript transcript(inner_proof.proof_data, - plonk::UltraComposer::create_manifest(num_inner_public_inputs), - transcript::HashType::PlookupPedersenBlake3s); - Widget value; for (auto _ : state) { - value.compute_quotient_contribution(FF::random_element(), transcript); + Widget value(inner_composer.circuit_proving_key.get()); + value.compute_quotient_contribution(FF::random_element(), inner_prover.transcript); } } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp index 311ead04ab0..6b4d3105bda 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp @@ -247,6 +247,8 @@ class FFTGetter : public BaseGetter 0); return polynomials.coefficients[id][(ptrdiff_t)index]; } }; @@ -316,6 +318,7 @@ class TransitionWidget : public TransitionWidgetBase { const transcript::StandardTranscript& transcript) override { auto* key = TransitionWidgetBase::key; + ASSERT(key != nullptr); // Get the set IDs for the polynomials required by the widget auto& required_polynomial_ids = FFTKernel::get_required_polynomial_ids(); diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp index ff4abf73113..91d06b788d2 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp @@ -210,7 +210,7 @@ void Transcript::apply_fiat_shamir(const std::string& challenge_name /*, const b if (current_round > 0) { buffer.insert(buffer.end(), current_challenge.data.begin(), current_challenge.data.end()); } - for (auto manifest_element : manifest.get_round_manifest(current_round).elements) { + for (const auto& manifest_element : manifest.get_round_manifest(current_round).elements) { info_togglable("apply_fiat_shamir(): manifest element name match:"); info_togglable("\t element name: ", manifest_element.name); info_togglable( From fbe3b19f2a6549f256e42ce73f24cc160354e65b Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 18 Oct 2023 15:16:23 -0400 Subject: [PATCH 4/8] fix: widget bench --- .../relations_bench/widget.bench.cpp | 12 ++++------ .../plonk/composer/ultra_composer.cpp | 23 +++++-------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp index d549f7e1281..d1d468b0f8f 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -12,25 +12,23 @@ auto& engine = numeric::random::get_debug_engine(); namespace proof_system::plonk { -using FF = barretenberg::fr; - template void execute_widget(::benchmark::State& state) { barretenberg::srs::init_crs_factory("../srs_db/ignition"); - auto inner_composer = plonk::StandardComposer(); - auto builder = typename plonk::StandardComposer::CircuitBuilder(); + auto inner_composer = plonk::UltraComposer(); + auto builder = typename plonk::UltraComposer::CircuitBuilder(); bench_utils::generate_basic_arithmetic_circuit(builder, 80); auto inner_prover = inner_composer.create_prover(builder); auto inner_proof = inner_prover.construct_proof(); for (auto _ : state) { - Widget value(inner_composer.circuit_proving_key.get()); - value.compute_quotient_contribution(FF::random_element(), inner_prover.transcript); + Widget widget(inner_composer.circuit_proving_key.get()); + widget.compute_quotient_contribution(barretenberg::fr::random_element(), inner_prover.transcript); } } void plookup_auxiliary_widget(::benchmark::State& state) noexcept { - execute_widget>(state); + execute_widget>(state); } BENCHMARK(plookup_auxiliary_widget); diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp index 1026193bdf7..2bd77756555 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp @@ -170,23 +170,12 @@ UltraProver UltraComposer::create_prover(CircuitBuilder& circuit_constructor) UltraProver output_state(circuit_proving_key, create_manifest(circuit_constructor.public_inputs.size())); - std::unique_ptr> permutation_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> plookup_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> arithmetic_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> sort_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> elliptic_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> auxiliary_widget = - std::make_unique>(circuit_proving_key.get()); + auto permutation_widget = std::make_unique>(circuit_proving_key.get()); + auto plookup_widget = std::make_unique>(circuit_proving_key.get()); + auto arithmetic_widget = std::make_unique>(circuit_proving_key.get()); + auto sort_widget = std::make_unique>(circuit_proving_key.get()); + auto elliptic_widget = std::make_unique>(circuit_proving_key.get()); + auto auxiliary_widget = std::make_unique>(circuit_proving_key.get()); output_state.random_widgets.emplace_back(std::move(permutation_widget)); output_state.random_widgets.emplace_back(std::move(plookup_widget)); From 14a84a841a263a6ccf6f04ff72c47f837f11400b Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 18 Oct 2023 17:30:03 -0400 Subject: [PATCH 5/8] fix: benchmarking --- .../relations_bench/relations.bench.cpp | 40 ++------------ .../relations_bench/widget.bench.cpp | 52 ++++++++++++++++--- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index 9e68ad32c60..3fce6156511 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -31,7 +31,9 @@ template void execute_relation(::benchmark: // Evaluate each constraint in the relation and check that each is satisfied for (auto _ : state) { - Relation::accumulate(accumulator, new_value, params, 1); + for (int i = 0; i < 1000; i++) { + Relation::accumulate(accumulator, new_value, params, 1); + } } } @@ -41,40 +43,4 @@ void auxiliary_relation(::benchmark::State& state) noexcept } BENCHMARK(auxiliary_relation); -void elliptic_relation(::benchmark::State& state) noexcept -{ - execute_relation>(state); -} -BENCHMARK(elliptic_relation); - -void ecc_op_queue_relation(::benchmark::State& state) noexcept -{ - execute_relation>(state); -} -BENCHMARK(ecc_op_queue_relation); - -void gen_perm_sort_relation(::benchmark::State& state) noexcept -{ - execute_relation>(state); -} -BENCHMARK(gen_perm_sort_relation); - -void lookup_relation(::benchmark::State& state) noexcept -{ - execute_relation>(state); -} -BENCHMARK(lookup_relation); - -void ultra_permutation_relation(::benchmark::State& state) noexcept -{ - execute_relation>(state); -} -BENCHMARK(ultra_permutation_relation); - -void ultra_arithmetic_relation(::benchmark::State& state) noexcept -{ - execute_relation>(state); -} -BENCHMARK(ultra_arithmetic_relation); - } // namespace proof_system::benchmark::relations diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp index d1d468b0f8f..0046f294da4 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -12,7 +12,12 @@ auto& engine = numeric::random::get_debug_engine(); namespace proof_system::plonk { -template void execute_widget(::benchmark::State& state) +struct BasicPlonkKeyAndTranscript { + std::shared_ptr proving_key; + transcript::StandardTranscript transcript; +}; + +BasicPlonkKeyAndTranscript get_plonk_key_and_transcript() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); auto inner_composer = plonk::UltraComposer(); @@ -20,16 +25,49 @@ template void execute_widget(::benchmark::Sta bench_utils::generate_basic_arithmetic_circuit(builder, 80); auto inner_prover = inner_composer.create_prover(builder); auto inner_proof = inner_prover.construct_proof(); + + return { inner_composer.circuit_proving_key, inner_prover.transcript }; +} + +template void execute_widget(::benchmark::State& state) +{ + BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); + Widget widget(data.proving_key); for (auto _ : state) { - Widget widget(inner_composer.circuit_proving_key.get()); - widget.compute_quotient_contribution(barretenberg::fr::random_element(), inner_prover.transcript); + for (int i = 0; i < 1000; i++) { + widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); + } } } - -void plookup_auxiliary_widget(::benchmark::State& state) noexcept +void plookup_auxiliary_kernel(::benchmark::State& state) noexcept { - execute_widget>(state); + BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); + + using FFTGetter = ProverPlookupAuxiliaryWidget::FFTGetter; + using FFTKernel = ProverPlookupAuxiliaryWidget::FFTKernel; + + auto polynomials = FFTGetter::get_polynomials(data.proving_key.get(), FFTKernel::get_required_polynomial_ids()); + auto challenges = FFTGetter::get_challenges( + data.transcript, barretenberg::fr::random_element(), FFTKernel::quotient_required_challenges); + + for (auto _ : state) { + for (int j = 0; j < 1000; j++) { + widget::containers::coefficient_array linear_terms; + FFTKernel::compute_linear_terms(polynomials, challenges, linear_terms, 0); + auto sum_of_linear_terms = FFTKernel::sum_linear_terms(polynomials, challenges, linear_terms, 0); + + auto& quotient_term = data.proving_key->quotient_polynomial_parts[0][0]; + quotient_term += sum_of_linear_terms; + FFTKernel::compute_non_linear_terms(polynomials, challenges, quotient_term, 0); + } + } } -BENCHMARK(plookup_auxiliary_widget); +BENCHMARK(plookup_auxiliary_kernel); + +// void plookup_auxiliary_widget(::benchmark::State& state) noexcept +//{ +// execute_widget>(state); +// } +// BENCHMARK(plookup_auxiliary_widget); } // namespace proof_system::plonk From b7ccfe08ed37db746443cbbd42970f3e833aad2b Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 18 Oct 2023 21:37:28 +0000 Subject: [PATCH 6/8] Finalize new widget bench --- .../relations_bench/widget.bench.cpp | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp index 0046f294da4..00572868e37 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -34,9 +34,7 @@ template void execute_widget(::benchmark::Sta BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); Widget widget(data.proving_key); for (auto _ : state) { - for (int i = 0; i < 1000; i++) { - widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); - } + widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); } } void plookup_auxiliary_kernel(::benchmark::State& state) noexcept @@ -51,23 +49,24 @@ void plookup_auxiliary_kernel(::benchmark::State& state) noexcept data.transcript, barretenberg::fr::random_element(), FFTKernel::quotient_required_challenges); for (auto _ : state) { - for (int j = 0; j < 1000; j++) { - widget::containers::coefficient_array linear_terms; - FFTKernel::compute_linear_terms(polynomials, challenges, linear_terms, 0); - auto sum_of_linear_terms = FFTKernel::sum_linear_terms(polynomials, challenges, linear_terms, 0); - - auto& quotient_term = data.proving_key->quotient_polynomial_parts[0][0]; - quotient_term += sum_of_linear_terms; - FFTKernel::compute_non_linear_terms(polynomials, challenges, quotient_term, 0); - } + // NOTE: this simply calls the following 3 functions it does NOT try to replicate ProverPlookupAuxiliaryWidget + // logic exactly + widget::containers::coefficient_array linear_terms; + FFTKernel::compute_linear_terms(polynomials, challenges, linear_terms, 0); + barretenberg::fr sum_of_linear_terms = FFTKernel::sum_linear_terms(polynomials, challenges, linear_terms, 0); + FFTKernel::compute_non_linear_terms(polynomials, challenges, sum_of_linear_terms, 0); } } BENCHMARK(plookup_auxiliary_kernel); -// void plookup_auxiliary_widget(::benchmark::State& state) noexcept -//{ -// execute_widget>(state); -// } -// BENCHMARK(plookup_auxiliary_widget); +void plookup_auxiliary_widget(::benchmark::State& state) noexcept +{ + BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); + ProverPlookupAuxiliaryWidget widget(data.proving_key.get()); + for (auto _ : state) { + widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); + } +} +BENCHMARK(plookup_auxiliary_widget); } // namespace proof_system::plonk From d574ba7395869ca5b65deefd1a2dd65e65c37d46 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 18 Oct 2023 21:39:13 +0000 Subject: [PATCH 7/8] Revert relations --- .../relations_bench/relations.bench.cpp | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index 3fce6156511..9e68ad32c60 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -31,9 +31,7 @@ template void execute_relation(::benchmark: // Evaluate each constraint in the relation and check that each is satisfied for (auto _ : state) { - for (int i = 0; i < 1000; i++) { - Relation::accumulate(accumulator, new_value, params, 1); - } + Relation::accumulate(accumulator, new_value, params, 1); } } @@ -43,4 +41,40 @@ void auxiliary_relation(::benchmark::State& state) noexcept } BENCHMARK(auxiliary_relation); +void elliptic_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(elliptic_relation); + +void ecc_op_queue_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(ecc_op_queue_relation); + +void gen_perm_sort_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(gen_perm_sort_relation); + +void lookup_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(lookup_relation); + +void ultra_permutation_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(ultra_permutation_relation); + +void ultra_arithmetic_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(ultra_arithmetic_relation); + } // namespace proof_system::benchmark::relations From 8d4de2e5a646c9c464eecd8b5ddd3877e783252d Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Oct 2023 03:42:56 +0000 Subject: [PATCH 8/8] fix: key --- .../benchmark/relations_bench/widget.bench.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp index 4f3fa76bb38..a47d1cc1460 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -13,7 +13,7 @@ auto& engine = numeric::random::get_debug_engine(); namespace proof_system::plonk { struct BasicPlonkKeyAndTranscript { - std::shared_ptr proving_key; + std::shared_ptr key; transcript::StandardTranscript transcript; }; @@ -31,7 +31,7 @@ BasicPlonkKeyAndTranscript get_plonk_key_and_transcript() template void execute_widget(::benchmark::State& state) { BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); - Widget widget(data.proving_key); + Widget widget(data.key); for (auto _ : state) { widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); } @@ -43,7 +43,7 @@ void plookup_auxiliary_kernel(::benchmark::State& state) noexcept using FFTGetter = ProverPlookupAuxiliaryWidget::FFTGetter; using FFTKernel = ProverPlookupAuxiliaryWidget::FFTKernel; - auto polynomials = FFTGetter::get_polynomials(data.proving_key.get(), FFTKernel::get_required_polynomial_ids()); + auto polynomials = FFTGetter::get_polynomials(data.key.get(), FFTKernel::get_required_polynomial_ids()); auto challenges = FFTGetter::get_challenges( data.transcript, barretenberg::fr::random_element(), FFTKernel::quotient_required_challenges); @@ -61,7 +61,7 @@ BENCHMARK(plookup_auxiliary_kernel); void plookup_auxiliary_widget(::benchmark::State& state) noexcept { BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); - ProverPlookupAuxiliaryWidget widget(data.proving_key.get()); + ProverPlookupAuxiliaryWidget widget(data.key.get()); for (auto _ : state) { widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); }