diff --git a/cpp/src/barretenberg/benchmark/CMakeLists.txt b/cpp/src/barretenberg/benchmark/CMakeLists.txt index 4a13dff54..968acb825 100644 --- a/cpp/src/barretenberg/benchmark/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/CMakeLists.txt @@ -5,4 +5,5 @@ add_subdirectory(plonk_bench) add_subdirectory(ultra_bench) add_subdirectory(goblin_bench) add_subdirectory(relations_bench) -add_subdirectory(widgets_bench) \ No newline at end of file +add_subdirectory(widgets_bench) +add_subdirectory(protogalaxy_bench) \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt new file mode 100644 index 000000000..75ba98e2d --- /dev/null +++ b/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt @@ -0,0 +1,20 @@ +# Each source represents a separate benchmark suite +set(BENCHMARK_SOURCES + protogalaxy.bench.cpp +) + +# Required libraries for benchmark suites +set(LINKED_LIBRARIES + ultra_honk + protogalaxy + stdlib_primitives + benchmark::benchmark +) + +# Add executable and custom target for each suite, e.g. ultra_honk_bench +foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES}) + get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension + add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE}) + target_link_libraries(${BENCHMARK_NAME}_bench ${LINKED_LIBRARIES}) + add_custom_target(run_${BENCHMARK_NAME} COMMAND ${BENCHMARK_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endforeach() \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/protogalaxy_bench/main.bench.cpp b/cpp/src/barretenberg/benchmark/protogalaxy_bench/main.bench.cpp new file mode 100644 index 000000000..71fefa047 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/protogalaxy_bench/main.bench.cpp @@ -0,0 +1,3 @@ +#include + +BENCHMARK_MAIN(); diff --git a/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp b/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp new file mode 100644 index 000000000..4153499e6 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -0,0 +1,41 @@ +#include + +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" +#include "barretenberg/ultra_honk/ultra_composer.hpp" + +using namespace benchmark; + +namespace proof_system::honk { +using Flavor = flavor::Ultra; +using Instance = ProverInstance_; +using Instances = ProverInstances_; +using ProtoGalaxyProver = ProtoGalaxyProver_; +using Builder = Flavor::CircuitBuilder; + +// Fold one instance into an accumulator. +void fold_one(State& state) noexcept +{ + barretenberg::srs::init_crs_factory("../srs_db/ignition"); + + auto log2_num_gates = static_cast(state.range(0)); + auto composer = UltraComposer(); + + const auto construct_instance = [&]() { + Builder builder; + bench_utils::generate_basic_arithmetic_circuit(builder, log2_num_gates); + return composer.create_instance(builder); + }; + + std::shared_ptr instance_1 = construct_instance(); + std::shared_ptr instance_2 = construct_instance(); + + auto folding_prover = composer.create_folding_prover({ instance_1, instance_2 }, composer.commitment_key); + + for (auto _ : state) { + auto proof = folding_prover.fold_instances(); + } +} + +BENCHMARK(fold_one)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond); +} // namespace proof_system::honk \ No newline at end of file diff --git a/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp b/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp index 0270afc5b..151b9e27f 100644 --- a/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp +++ b/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp @@ -91,7 +91,7 @@ template class ProtoGalaxyProver_ { * * TODO(https://github.com/AztecProtocol/barretenberg/issues/753): fold goblin polynomials */ - FoldingResult fold_instances(); + BBERG_PROFILE FoldingResult fold_instances(); /** * @brief For a new round challenge δ at each iteration of the ProtoGalaxy protocol, compute the vector