-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Benchmark protogalaxy prover (#3958)
Benchmark Protogalaxy prover. This just benchmarks the current folding function. Future PRs will make update and augment with values that will better reflect performance in production. Results: uses 16 cores (for the x86 build). `fold_one/N` measures the time to call the `fold_instances` function to fold a single instance into an accumulator where the instance sizes are $2^N$. Note this is for the Ultra arithmetization (so no Goblin, Poseidon2 or DataBus relations). ``` % taskset -c 0-15 ./bin/protogalaxy_bench 38s ~/barretenberg-cpp/build cg/pg-bench mainframe 2024-01-11T19:39:49+00:00 Running ./bin/protogalaxy_bench Run on (128 X 2649.99 MHz CPU s) CPU Caches: L1 Data 32 KiB (x64) L1 Instruction 32 KiB (x64) L2 Unified 512 KiB (x64) L3 Unified 32768 KiB (x8) Load Average: 3.48, 8.51, 27.24 ------------------------------------------------------ Benchmark Time CPU Iterations ------------------------------------------------------ fold_one/14 417 ms 259 ms 3 fold_one/15 668 ms 409 ms 2 fold_one/16 1158 ms 696 ms 1 fold_one/17 2245 ms 1433 ms 1 fold_one/18 4168 ms 2644 ms 1 fold_one/19 7890 ms 5119 ms 1 fold_one/20 15809 ms 10633 ms 1 ``` Closes AztecProtocol/barretenberg#692
- Loading branch information
1 parent
a9537fb
commit 5843722
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
3 changes: 3 additions & 0 deletions
3
barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/main.bench.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
BENCHMARK_MAIN(); |
41 changes: 41 additions & 0 deletions
41
barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters