Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Benchmark protogalaxy prover #3958

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ add_subdirectory(plonk_bench)
add_subdirectory(ultra_bench)
add_subdirectory(goblin_bench)
add_subdirectory(relations_bench)
add_subdirectory(widgets_bench)
add_subdirectory(widgets_bench)
add_subdirectory(protogalaxy_bench)
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <benchmark/benchmark.h>

BENCHMARK_MAIN();
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <benchmark/benchmark.h>

#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_<Flavor>;
using Instances = ProverInstances_<Flavor, 2>;
using ProtoGalaxyProver = ProtoGalaxyProver_<Instances>;
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<size_t>(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> instance_1 = construct_instance();
std::shared_ptr<Instance> 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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
*
* TODO(https://github.com/AztecProtocol/barretenberg/issues/753): fold goblin polynomials
*/
FoldingResult<Flavor> fold_instances();
BBERG_PROFILE FoldingResult<Flavor> fold_instances();

/**
* @brief For a new round challenge δ at each iteration of the ProtoGalaxy protocol, compute the vector
Expand Down