diff --git a/barretenberg/cpp/scripts/analyze_client_ivc_bench.py b/barretenberg/cpp/scripts/analyze_client_ivc_bench.py index d9b5e047b1f..c462b9771f1 100644 --- a/barretenberg/cpp/scripts/analyze_client_ivc_bench.py +++ b/barretenberg/cpp/scripts/analyze_client_ivc_bench.py @@ -7,8 +7,7 @@ # Single out an independent set of functions accounting for most of BENCHMARK's real_time to_keep = [ - "construct_mock_function_circuit(t)", - "construct_mock_folding_kernel(t)", + "construct_circuits(t)", "ProverInstance(Circuit&)(t)", "ProtogalaxyProver::fold_instances(t)", "Decider::construct_proof(t)", diff --git a/barretenberg/cpp/scripts/benchmark.sh b/barretenberg/cpp/scripts/benchmark.sh index 93b96377173..6b6758700f4 100755 --- a/barretenberg/cpp/scripts/benchmark.sh +++ b/barretenberg/cpp/scripts/benchmark.sh @@ -2,16 +2,19 @@ set -eu BENCHMARK=${1:-goblin_bench} -COMMAND=${2:-./bin/$BENCHMARK} +COMMAND=${2:-./$BENCHMARK} +PRESET=${3:-clang16} +BUILD_DIR=${4:-build} + # Move above script dir. cd $(dirname $0)/.. # Configure and build. -cmake --preset clang16 -cmake --build --preset clang16 --target $BENCHMARK +cmake --preset $PRESET +cmake --build --preset $PRESET --target $BENCHMARK -cd build +cd $BUILD_DIR # Consistency with _wasm.sh targets / shorter $COMMAND. cp ./bin/$BENCHMARK . $COMMAND \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp index f65385da92e..2ace58eb6e6 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp @@ -2,6 +2,7 @@ #include #include "barretenberg/client_ivc/client_ivc.hpp" +#include "barretenberg/common/op_count.hpp" #include "barretenberg/common/op_count_google_bench.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" @@ -46,9 +47,12 @@ class ClientIVCBench : public benchmark::Fixture { std::vector initial_function_circuits(2); // Construct 2 starting function circuits in parallel - parallel_for(2, [&](size_t circuit_index) { - GoblinMockCircuits::construct_mock_function_circuit(initial_function_circuits[circuit_index]); - }); + { + BB_OP_COUNT_TIME_NAME("construct_circuits"); + parallel_for(2, [&](size_t circuit_index) { + GoblinMockCircuits::construct_mock_function_circuit(initial_function_circuits[circuit_index]); + }); + }; // Prepend queue to the first circuit initial_function_circuits[0].op_queue->prepend_previous_queue(*ivc.goblin.op_queue); @@ -81,25 +85,28 @@ class ClientIVCBench : public benchmark::Fixture { Builder kernel_circuit{ size_hint, ivc.goblin.op_queue }; Builder function_circuit{ size_hint }; // Construct function and kernel circuits in parallel - parallel_for(2, [&](size_t workload_idx) { - // workload index is 0 for kernel and 1 for function - if (workload_idx == 0) { - if (circuit_idx == 0) { - - // Create the first folding kernel which only verifies the accumulation of a - // function circuit - kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( - kernel_circuit, function_fold_output, {}, kernel_verifier_accumulator); + { + BB_OP_COUNT_TIME_NAME("construct_circuits"); + parallel_for(2, [&](size_t workload_idx) { + // workload index is 0 for kernel and 1 for function + if (workload_idx == 0) { + if (circuit_idx == 0) { + + // Create the first folding kernel which only verifies the accumulation of a + // function circuit + kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( + kernel_circuit, function_fold_output, {}, kernel_verifier_accumulator); + } else { + // Create kernel circuit containing the recursive folding verification of a function circuit + // and a kernel circuit + kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( + kernel_circuit, function_fold_output, kernel_fold_output, kernel_verifier_accumulator); + } } else { - // Create kernel circuit containing the recursive folding verification of a function circuit and - // a kernel circuit - kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( - kernel_circuit, function_fold_output, kernel_fold_output, kernel_verifier_accumulator); + GoblinMockCircuits::construct_mock_function_circuit(function_circuit); } - } else { - GoblinMockCircuits::construct_mock_function_circuit(function_circuit); - } - }); + }); + }; // No need to prepend queue, it's the same after last swap // Accumulate kernel circuit @@ -127,14 +134,20 @@ class ClientIVCBench : public benchmark::Fixture { // Create and accumulate the first folding kernel which only verifies the accumulation of a function circuit Builder kernel_circuit{ size_hint, ivc.goblin.op_queue }; auto kernel_verifier_accumulator = std::make_shared(ivc.vks.first_func_vk); - kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( - kernel_circuit, function_fold_output, {}, kernel_verifier_accumulator); + { + BB_OP_COUNT_TIME_NAME("construct_circuits"); + kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( + kernel_circuit, function_fold_output, {}, kernel_verifier_accumulator); + } auto kernel_fold_proof = ivc.accumulate(kernel_circuit); kernel_fold_output = { kernel_fold_proof, ivc.vks.first_kernel_vk }; } else { Builder kernel_circuit{ size_hint, ivc.goblin.op_queue }; - kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( - kernel_circuit, function_fold_output, kernel_fold_output, kernel_verifier_accumulator); + { + BB_OP_COUNT_TIME_NAME("construct_circuits"); + kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( + kernel_circuit, function_fold_output, kernel_fold_output, kernel_verifier_accumulator); + } auto kernel_fold_proof = ivc.accumulate(kernel_circuit); kernel_fold_output = { kernel_fold_proof, ivc.vks.kernel_vk }; diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index 884e5c27ab8..58cc8fc2d2c 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -109,7 +109,6 @@ class GoblinMockCircuits { */ static void construct_mock_function_circuit(GoblinUltraBuilder& builder, bool large = false) { - BB_OP_COUNT_TIME(); // Determine number of times to execute the below operations that constitute the mock circuit logic. Note that // the circuit size does not scale linearly with number of iterations due to e.g. amortization of lookup costs const size_t NUM_ITERATIONS_LARGE = 13; // results in circuit size 2^19 (521327 gates) @@ -233,7 +232,6 @@ class GoblinMockCircuits { const VerifierFoldData& kernel, std::shared_ptr& prev_kernel_accum) { - BB_OP_COUNT_TIME(); using GURecursiveFlavor = GoblinUltraRecursiveFlavor_; using RecursiveVerifierInstances = bb::stdlib::recursion::honk::RecursiveVerifierInstances_;