From 06921a8dd7c424a4c719d0dad9e7c8321c05d352 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 2 Jun 2023 21:53:54 +0000 Subject: [PATCH 01/24] comparison scripts in place for plonk vs honk standard and ultra --- .../benchmark/honk_bench/CMakeLists.txt | 56 ++++++- .../honk_bench/benchmark_utilities.hpp | 156 ++++++++++++++++++ .../honk_bench/compare_standard_bench.sh | 41 +++++ .../honk_bench/compare_ultra_bench.sh | 41 +++++ .../honk_bench/standard_honk.bench.cpp | 59 +++++++ .../honk_bench/standard_plonk.bench.cpp | 59 +++++++ .../benchmark/honk_bench/ultra_honk.bench.cpp | 135 ++------------- .../honk_bench/ultra_plonk.bench.cpp | 69 ++++++++ 8 files changed, 494 insertions(+), 122 deletions(-) create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp create mode 100755 cpp/src/barretenberg/benchmark/honk_bench/compare_standard_bench.sh create mode 100755 cpp/src/barretenberg/benchmark/honk_bench/compare_ultra_bench.sh create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp diff --git a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index a521b94cdc..4251be3d3a 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -1,7 +1,10 @@ -add_executable(honk_bench main.bench.cpp honk.bench.cpp ultra_honk.bench.cpp) +add_executable(standard_honk_bench main.bench.cpp standard_honk.bench.cpp) +add_executable(standard_plonk_bench main.bench.cpp standard_plonk.bench.cpp) +add_executable(ultra_honk_bench main.bench.cpp ultra_honk.bench.cpp) +add_executable(ultra_plonk_bench main.bench.cpp ultra_plonk.bench.cpp) target_link_libraries( - honk_bench + standard_honk_bench stdlib_primitives common stdlib_sha256 @@ -11,8 +14,53 @@ target_link_libraries( benchmark::benchmark ) +target_link_libraries( + standard_plonk_bench + stdlib_primitives + stdlib_sha256 + stdlib_keccak + stdlib_merkle_tree + env + benchmark::benchmark +) + +target_link_libraries( + ultra_honk_bench + stdlib_primitives + stdlib_sha256 + stdlib_keccak + stdlib_merkle_tree + env + benchmark::benchmark +) + +target_link_libraries( + ultra_plonk_bench + stdlib_primitives + stdlib_sha256 + stdlib_keccak + stdlib_merkle_tree + env + benchmark::benchmark +) + +add_custom_target( + run_standard_honk_bench + COMMAND standard_honk_bench + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +) +add_custom_target( + run_standard_plonk_bench + COMMAND standard_plonk_bench + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +) +add_custom_target( + run_ultra_honk_bench + COMMAND ultra_honk_bench + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +) add_custom_target( - run_honk_bench - COMMAND honk_bench + run_ultra_plonk_bench + COMMAND ultra_plonk_bench WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp new file mode 100644 index 0000000000..782701f0f2 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -0,0 +1,156 @@ +#include "barretenberg/crypto/ecdsa/ecdsa.hpp" +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/honk/proof_system/ultra_prover.hpp" +#include "barretenberg/honk/proof_system/ultra_verifier.hpp" +#include +#include +#include "barretenberg/honk/composer/standard_honk_composer.hpp" +#include "barretenberg/plonk/composer/standard_plonk_composer.hpp" +#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" +#include "barretenberg/stdlib/hash/keccak/keccak.hpp" +#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" +#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" +#include "barretenberg/stdlib/hash/sha256/sha256.hpp" +#include "barretenberg/stdlib/primitives/bool/bool.hpp" +#include "barretenberg/stdlib/primitives/field/field.hpp" +#include "barretenberg/stdlib/primitives/witness/witness.hpp" +#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" +#include "barretenberg/stdlib/merkle_tree/membership.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" + +using namespace benchmark; + +namespace bench_utils { + +/** + * @brief Generate test circuit with basic arithmetic operations + * + * @param composer + * @param num_iterations + */ +template void generate_basic_arithmetic_circuit(Composer& composer, size_t num_gates) +{ + plonk::stdlib::field_t a(plonk::stdlib::witness_t(&composer, barretenberg::fr::random_element())); + plonk::stdlib::field_t b(plonk::stdlib::witness_t(&composer, barretenberg::fr::random_element())); + plonk::stdlib::field_t c(&composer); + for (size_t i = 0; i < (num_gates / 4) - 4; ++i) { + c = a + b; + c = a * c; + a = b * b; + b = c * c; + } +} + +/** + * @brief Generate test circuit with specified number of sha256 hashes + * + * @param composer + * @param num_iterations + */ +template void generate_sha256_test_circuit(Composer& composer, size_t num_iterations) +{ + std::string in; + in.resize(32); + for (size_t i = 0; i < 32; ++i) { + in[i] = 0; + } + proof_system::plonk::stdlib::packed_byte_array input(&composer, in); + for (size_t i = 0; i < num_iterations; i++) { + input = proof_system::plonk::stdlib::sha256(input); + } +} + +/** + * @brief Generate test circuit with specified number of keccak hashes + * + * @param composer + * @param num_iterations + */ +template void generate_keccak_test_circuit(Composer& composer, size_t num_iterations) +{ + std::string in = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"; + + proof_system::plonk::stdlib::byte_array input(&composer, in); + for (size_t i = 0; i < num_iterations; i++) { + input = proof_system::plonk::stdlib::keccak::hash(input); + } +} + +/** + * @brief Generate test circuit with specified number of ecdsa verifications + * + * @param composer + * @param num_iterations + */ +template void generate_ecdsa_verification_test_circuit(Composer& composer, size_t num_iterations) +{ + using curve = proof_system::plonk::stdlib::secp256k1; + using fr = typename curve::fr; + using fq = typename curve::fq; + using g1 = typename curve::g1; + + std::string message_string = "Instructions unclear, ask again later."; + + crypto::ecdsa::key_pair account; + account.private_key = curve::fr::random_element(); + account.public_key = curve::g1::one * account.private_key; + + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, account); + + bool first_result = + crypto::ecdsa::verify_signature(message_string, account.public_key, signature); + + std::vector rr(signature.r.begin(), signature.r.end()); + std::vector ss(signature.s.begin(), signature.s.end()); + uint8_t vv = signature.v; + + typename curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&composer, account.public_key); + + proof_system::plonk::stdlib::ecdsa::signature sig{ typename curve::byte_array_ct(&composer, rr), + typename curve::byte_array_ct(&composer, ss), + proof_system::plonk::stdlib::uint8(&composer, + vv) }; + + typename curve::byte_array_ct message(&composer, message_string); + + for (size_t i = 0; i < num_iterations; i++) { + proof_system::plonk::stdlib::ecdsa::verify_signature(message, public_key, sig); + } +} + +/** + * @brief Generate test circuit with specified number of merkle membership checks + * + * @param composer + * @param num_iterations + * @todo (luke): should we consider deeper tree? non-zero leaf values? variable index? + */ +template void generate_merkle_membership_test_circuit(Composer& composer, size_t num_iterations) +{ + using namespace proof_system::plonk::stdlib; + using field_ct = field_t; + using witness_ct = witness_t; + using witness_ct = witness_t; + using MemStore = merkle_tree::MemoryStore; + using MerkleTree_ct = merkle_tree::MerkleTree; + + MemStore store; + auto db = MerkleTree_ct(store, 3); + + // Check that the leaf at index 0 has value 0. + auto zero = field_ct(witness_ct(&composer, fr::zero())).decompose_into_bits(); + field_ct root = witness_ct(&composer, db.root()); + + for (size_t i = 0; i < num_iterations; i++) { + merkle_tree::check_membership( + root, merkle_tree::create_witness_hash_path(composer, db.get_hash_path(0)), field_ct(0), zero); + } +} + +} // namespace bench_utils \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_standard_bench.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_standard_bench.sh new file mode 100755 index 0000000000..f30bb4d26c --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_standard_bench.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# This script is used to compare the results of honk_bench between baseline (master) and +# the branch from which the script is run. Simply check out the branch of interest, ensure +# it is up to date with local master, and run the script. + +echo -e '\nComparing Standard Plonk/Honk benchmarks.' +# Set some directories +BASE_DIR="$HOME/barretenberg/cpp" +BUILD_DIR="$BASE_DIR/build-bench" +BENCH_RESULTS_DIR="$BASE_DIR/tmp_bench_results" +BENCH_TOOLS_DIR="$BUILD_DIR/_deps/benchmark-src/tools" + +# Install requirements (numpy + scipy) for comparison script if necessary. +# Note: By default, installation will occur in $HOME/.local/bin. +pip3 install -r $BUILD_DIR/_deps/benchmark-src/requirements.txt + +# Create temporary directory for honk_bench results (json) +cd $BASE_DIR +mkdir $BENCH_RESULTS_DIR + +# +echo -e '\nBuilding and running Standard benchmarks..' +# rm -rf $BUILD_DIR +cmake --preset bench > /dev/null && cmake --build --preset bench --target standard_plonk_bench +cd build-bench +PLONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/plonk_bench.json" +./bin/standard_plonk_bench --benchmark_format=json > $PLONK_BENCH_RESULTS + +cd .. +cmake --preset bench > /dev/null && cmake --build --preset bench --target standard_honk_bench +cd build-bench +HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench.json" +./bin/standard_honk_bench --benchmark_format=json > $HONK_BENCH_RESULTS + +# Call compare.py on the results (json) to get high level statistics. +# See docs at https://github.com/google/benchmark/blob/main/docs/tools.md for more details. +$BENCH_TOOLS_DIR/compare.py benchmarks $PLONK_BENCH_RESULTS $HONK_BENCH_RESULTS + +# # Delete the temporary results directory and its contents +rm -r $BENCH_RESULTS_DIR \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_ultra_bench.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_ultra_bench.sh new file mode 100755 index 0000000000..bba5ed9da8 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_ultra_bench.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# This script is used to compare the results of honk_bench between baseline (master) and +# the branch from which the script is run. Simply check out the branch of interest, ensure +# it is up to date with local master, and run the script. + +echo -e '\nComparing Ultra Plonk/Honk benchmarks.' +# Set some directories +BASE_DIR="$HOME/barretenberg/cpp" +BUILD_DIR="$BASE_DIR/build-bench" +BENCH_RESULTS_DIR="$BASE_DIR/tmp_bench_results" +BENCH_TOOLS_DIR="$BUILD_DIR/_deps/benchmark-src/tools" + +# Install requirements (numpy + scipy) for comparison script if necessary. +# Note: By default, installation will occur in $HOME/.local/bin. +pip3 install -r $BUILD_DIR/_deps/benchmark-src/requirements.txt + +# Create temporary directory for honk_bench results (json) +cd $BASE_DIR +mkdir $BENCH_RESULTS_DIR + +# +echo -e '\nBuilding and running Standard benchmarks..' +# rm -rf $BUILD_DIR +cmake --preset bench > /dev/null && cmake --build --preset bench --target ultra_plonk_bench +cd build-bench +PLONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/plonk_bench.json" +./bin/ultra_plonk_bench --benchmark_format=json > $PLONK_BENCH_RESULTS + +cd .. +cmake --preset bench > /dev/null && cmake --build --preset bench --target ultra_honk_bench +cd build-bench +HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench.json" +./bin/ultra_honk_bench --benchmark_format=json > $HONK_BENCH_RESULTS + +# Call compare.py on the results (json) to get high level statistics. +# See docs at https://github.com/google/benchmark/blob/main/docs/tools.md for more details. +$BENCH_TOOLS_DIR/compare.py benchmarks $PLONK_BENCH_RESULTS $HONK_BENCH_RESULTS + +# # Delete the temporary results directory and its contents +rm -r $BENCH_RESULTS_DIR \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp new file mode 100644 index 0000000000..65b026c706 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp @@ -0,0 +1,59 @@ +#include "barretenberg/crypto/ecdsa/ecdsa.hpp" +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/honk/proof_system/ultra_prover.hpp" +#include "barretenberg/honk/proof_system/ultra_verifier.hpp" +#include +#include +#include "barretenberg/honk/composer/standard_honk_composer.hpp" +#include "barretenberg/plonk/composer/standard_plonk_composer.hpp" +#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" +#include "barretenberg/stdlib/hash/keccak/keccak.hpp" +#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" +#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" +#include "barretenberg/stdlib/hash/sha256/sha256.hpp" +#include "barretenberg/stdlib/primitives/bool/bool.hpp" +#include "barretenberg/stdlib/primitives/field/field.hpp" +#include "barretenberg/stdlib/primitives/witness/witness.hpp" +#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" +#include "barretenberg/stdlib/merkle_tree/membership.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" +#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" + +using namespace benchmark; + +namespace standard_honk_bench { + +using StandardHonk = proof_system::honk::StandardHonkComposer; + +// Log number of gates for test circuit +constexpr size_t MIN_LOG_NUM_GATES = 16; +constexpr size_t MAX_LOG_NUM_GATES = 16; +// Number of times to repeat each benchmark +constexpr size_t NUM_REPETITIONS = 1; + +/** + * @brief Benchmark: Construction of a Standard proof for a circuit determined by the provided circuit function + */ +template +void construct_proof_standard(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +{ + auto num_gates = static_cast(1 << (size_t)state.range(0)); + for (auto _ : state) { + // Constuct circuit and prover; don't include this part in measurement + state.PauseTiming(); + auto composer = Composer(); + test_circuit_function(composer, num_gates); + auto ext_prover = composer.create_prover(); + state.ResumeTiming(); + + // Construct proof + auto proof = ext_prover.construct_proof(); + } +} + +BENCHMARK_CAPTURE(construct_proof_standard, arithmetic, &bench_utils::generate_basic_arithmetic_circuit) + ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES) + ->Repetitions(NUM_REPETITIONS); + +} // namespace standard_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp new file mode 100644 index 0000000000..beed17e08b --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp @@ -0,0 +1,59 @@ +#include "barretenberg/crypto/ecdsa/ecdsa.hpp" +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/honk/proof_system/ultra_prover.hpp" +#include "barretenberg/honk/proof_system/ultra_verifier.hpp" +#include +#include +#include "barretenberg/honk/composer/standard_honk_composer.hpp" +#include "barretenberg/plonk/composer/standard_plonk_composer.hpp" +#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" +#include "barretenberg/stdlib/hash/keccak/keccak.hpp" +#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" +#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" +#include "barretenberg/stdlib/hash/sha256/sha256.hpp" +#include "barretenberg/stdlib/primitives/bool/bool.hpp" +#include "barretenberg/stdlib/primitives/field/field.hpp" +#include "barretenberg/stdlib/primitives/witness/witness.hpp" +#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" +#include "barretenberg/stdlib/merkle_tree/membership.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" +#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" + +using namespace benchmark; + +namespace standard_plonk_bench { + +using StandardPlonk = proof_system::plonk::StandardPlonkComposer; + +// Log number of gates for test circuit +constexpr size_t MIN_LOG_NUM_GATES = 16; +constexpr size_t MAX_LOG_NUM_GATES = 16; +// Number of times to repeat each benchmark +constexpr size_t NUM_REPETITIONS = 1; + +/** + * @brief Benchmark: Construction of a Standard proof for a circuit determined by the provided circuit function + */ +template +void construct_proof_standard(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +{ + auto num_gates = static_cast(1 << (size_t)state.range(0)); + for (auto _ : state) { + // Constuct circuit and prover; don't include this part in measurement + state.PauseTiming(); + auto composer = Composer(); + test_circuit_function(composer, num_gates); + auto ext_prover = composer.create_prover(); + state.ResumeTiming(); + + // Construct proof + auto proof = ext_prover.construct_proof(); + } +} + +BENCHMARK_CAPTURE(construct_proof_standard, arithmetic, &bench_utils::generate_basic_arithmetic_circuit) + ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES) + ->Repetitions(NUM_REPETITIONS); + +} // namespace standard_plonk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index 8a6f7933e4..ba076f3db8 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -16,12 +16,13 @@ #include "barretenberg/stdlib/merkle_tree/membership.hpp" #include "barretenberg/stdlib/merkle_tree/memory_store.hpp" #include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" +#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" using namespace benchmark; namespace ultra_honk_bench { -using Composer = proof_system::honk::UltraHonkComposer; +using UltraHonk = proof_system::honk::UltraHonkComposer; // Number of times to perform operation of interest in the benchmark circuits, e.g. # of hashes to perform constexpr size_t MIN_NUM_ITERATIONS = 10; @@ -29,140 +30,38 @@ constexpr size_t MAX_NUM_ITERATIONS = 10; // Number of times to repeat each benchmark constexpr size_t NUM_REPETITIONS = 1; -/** - * @brief Generate test circuit with specified number of sha256 hashes - * - * @param composer - * @param num_iterations - */ -void generate_sha256_test_circuit(Composer& composer, size_t num_iterations) -{ - std::string in; - in.resize(32); - for (size_t i = 0; i < 32; ++i) { - in[i] = 0; - } - proof_system::plonk::stdlib::packed_byte_array input(&composer, in); - for (size_t i = 0; i < num_iterations; i++) { - input = proof_system::plonk::stdlib::sha256(input); - } -} - -/** - * @brief Generate test circuit with specified number of keccak hashes - * - * @param composer - * @param num_iterations - */ -void generate_keccak_test_circuit(Composer& composer, size_t num_iterations) -{ - std::string in = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"; - - proof_system::plonk::stdlib::byte_array input(&composer, in); - for (size_t i = 0; i < num_iterations; i++) { - input = proof_system::plonk::stdlib::keccak::hash(input); - } -} - -/** - * @brief Generate test circuit with specified number of ecdsa verifications - * - * @param composer - * @param num_iterations - */ -void generate_ecdsa_verification_test_circuit(Composer& composer, size_t num_iterations) -{ - using curve = proof_system::plonk::stdlib::secp256k1; - - std::string message_string = "Instructions unclear, ask again later."; - - crypto::ecdsa::key_pair account; - account.private_key = curve::fr::random_element(); - account.public_key = curve::g1::one * account.private_key; - - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, account); - - bool first_result = crypto::ecdsa::verify_signature( - message_string, account.public_key, signature); - - std::vector rr(signature.r.begin(), signature.r.end()); - std::vector ss(signature.s.begin(), signature.s.end()); - uint8_t vv = signature.v; - - curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&composer, account.public_key); - - proof_system::plonk::stdlib::ecdsa::signature sig{ curve::byte_array_ct(&composer, rr), - curve::byte_array_ct(&composer, ss), - proof_system::plonk::stdlib::uint8(&composer, - vv) }; - - curve::byte_array_ct message(&composer, message_string); - - for (size_t i = 0; i < num_iterations; i++) { - proof_system::plonk::stdlib::ecdsa:: - verify_signature( - message, public_key, sig); - } -} - -/** - * @brief Generate test circuit with specified number of merkle membership checks - * - * @param composer - * @param num_iterations - * @todo (luke): should we consider deeper tree? non-zero leaf values? variable index? - */ -void generate_merkle_membership_test_circuit(Composer& composer, size_t num_iterations) -{ - using namespace proof_system::plonk::stdlib; - using field_ct = field_t; - using witness_ct = witness_t; - using witness_ct = witness_t; - using MemStore = merkle_tree::MemoryStore; - using MerkleTree_ct = merkle_tree::MerkleTree; - - MemStore store; - auto db = MerkleTree_ct(store, 3); - - // Check that the leaf at index 0 has value 0. - auto zero = field_ct(witness_ct(&composer, fr::zero())).decompose_into_bits(); - field_ct root = witness_ct(&composer, db.root()); - - for (size_t i = 0; i < num_iterations; i++) { - merkle_tree::check_membership( - root, merkle_tree::create_witness_hash_path(composer, db.get_hash_path(0)), field_ct(0), zero); - } -} - /** * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided text circuit function */ -void construct_proof_ultra(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +template +void construct_proof(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept { auto num_iterations = static_cast(state.range(0)); for (auto _ : state) { + // Constuct circuit and prover; don't include this part in measurement state.PauseTiming(); auto composer = Composer(); test_circuit_function(composer, num_iterations); auto ext_prover = composer.create_prover(); state.ResumeTiming(); + info("composer.num_gates = ", composer.num_gates); + // Construct proof auto proof = ext_prover.construct_proof(); } } -BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &generate_sha256_test_circuit) - ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &generate_keccak_test_circuit) - ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof_ultra, ecdsa_verification, &generate_ecdsa_verification_test_circuit) - ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof_ultra, merkle_membership, &generate_merkle_membership_test_circuit) +BENCHMARK_CAPTURE(construct_proof, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); +// BENCHMARK_CAPTURE(construct_proof, keccak, &generate_keccak_test_circuit) +// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) +// ->Repetitions(NUM_REPETITIONS); +// BENCHMARK_CAPTURE(construct_proof, ecdsa_verification, &generate_ecdsa_verification_test_circuit) +// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) +// ->Repetitions(NUM_REPETITIONS); +// BENCHMARK_CAPTURE(construct_proof, merkle_membership, &generate_merkle_membership_test_circuit) +// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) +// ->Repetitions(NUM_REPETITIONS); } // namespace ultra_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp new file mode 100644 index 0000000000..fe6a18fd15 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp @@ -0,0 +1,69 @@ +#include "barretenberg/crypto/ecdsa/ecdsa.hpp" +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/honk/proof_system/ultra_prover.hpp" +#include "barretenberg/honk/proof_system/ultra_verifier.hpp" +#include +#include +#include "barretenberg/honk/composer/ultra_honk_composer.hpp" +#include "barretenberg/plonk/composer/ultra_plonk_composer.hpp" +#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" +#include "barretenberg/stdlib/hash/keccak/keccak.hpp" +#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" +#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" +#include "barretenberg/stdlib/hash/sha256/sha256.hpp" +#include "barretenberg/stdlib/primitives/bool/bool.hpp" +#include "barretenberg/stdlib/primitives/field/field.hpp" +#include "barretenberg/stdlib/primitives/witness/witness.hpp" +#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" +#include "barretenberg/stdlib/merkle_tree/membership.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" +#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" + +using namespace benchmark; + +namespace ultra_plonk_bench { + +using UltraPlonk = proof_system::plonk::UltraPlonkComposer; + +// Number of times to perform operation of interest in the benchmark circuits, e.g. # of hashes to perform +constexpr size_t MIN_NUM_ITERATIONS = 10; +constexpr size_t MAX_NUM_ITERATIONS = 10; +// Number of times to repeat each benchmark +constexpr size_t NUM_REPETITIONS = 1; + +/** + * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided text circuit function + */ +template +void construct_proof(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +{ + auto num_iterations = static_cast(state.range(0)); + for (auto _ : state) { + // Constuct circuit and prover; don't include this part in measurement + state.PauseTiming(); + auto composer = Composer(); + test_circuit_function(composer, num_iterations); + auto ext_prover = composer.create_prover(); + state.ResumeTiming(); + info("composer.num_gates = ", composer.num_gates); + + // Construct proof + auto proof = ext_prover.construct_proof(); + } +} + +BENCHMARK_CAPTURE(construct_proof, sha256, &bench_utils::generate_sha256_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +// BENCHMARK_CAPTURE(construct_proof, keccak, &generate_keccak_test_circuit) +// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) +// ->Repetitions(NUM_REPETITIONS); +// BENCHMARK_CAPTURE(construct_proof, ecdsa_verification, &generate_ecdsa_verification_test_circuit) +// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) +// ->Repetitions(NUM_REPETITIONS); +// BENCHMARK_CAPTURE(construct_proof, merkle_membership, &generate_merkle_membership_test_circuit) +// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) +// ->Repetitions(NUM_REPETITIONS); + +} // namespace ultra_plonk_bench \ No newline at end of file From 41b83beafedfec82f97affc16fa84ddbc9c3c41c Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 5 Jun 2023 20:26:40 +0000 Subject: [PATCH 02/24] activate all ultra BMs --- .../honk_bench/benchmark_utilities.hpp | 12 +++++++++ .../honk_bench/standard_honk.bench.cpp | 6 ++--- .../honk_bench/standard_plonk.bench.cpp | 6 ++--- .../benchmark/honk_bench/ultra_honk.bench.cpp | 27 ++++++++++--------- .../honk_bench/ultra_plonk.bench.cpp | 27 ++++++++++--------- 5 files changed, 46 insertions(+), 32 deletions(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 782701f0f2..23c8ad33bd 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -23,6 +23,18 @@ using namespace benchmark; namespace bench_utils { +struct BenchParams { + // Num iterations of the operation of interest in a test circuit, e.g. num sha256 hashes + static constexpr size_t MIN_NUM_ITERATIONS = 10; + static constexpr size_t MAX_NUM_ITERATIONS = 10; + + // Log num gates; for simple circuits only, e.g. standard arithmetic circuit + static constexpr size_t MIN_LOG_NUM_GATES = 16; + static constexpr size_t MAX_LOG_NUM_GATES = 16; + + static constexpr size_t NUM_REPETITIONS = 1; +}; + /** * @brief Generate test circuit with basic arithmetic operations * diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp index 65b026c706..993523c327 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp @@ -27,10 +27,10 @@ namespace standard_honk_bench { using StandardHonk = proof_system::honk::StandardHonkComposer; // Log number of gates for test circuit -constexpr size_t MIN_LOG_NUM_GATES = 16; -constexpr size_t MAX_LOG_NUM_GATES = 16; +constexpr size_t MIN_LOG_NUM_GATES = bench_utils::BenchParams::MIN_LOG_NUM_GATES; +constexpr size_t MAX_LOG_NUM_GATES = bench_utils::BenchParams::MAX_LOG_NUM_GATES; // Number of times to repeat each benchmark -constexpr size_t NUM_REPETITIONS = 1; +constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** * @brief Benchmark: Construction of a Standard proof for a circuit determined by the provided circuit function diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp index beed17e08b..e168edd295 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp @@ -27,10 +27,10 @@ namespace standard_plonk_bench { using StandardPlonk = proof_system::plonk::StandardPlonkComposer; // Log number of gates for test circuit -constexpr size_t MIN_LOG_NUM_GATES = 16; -constexpr size_t MAX_LOG_NUM_GATES = 16; +constexpr size_t MIN_LOG_NUM_GATES = bench_utils::BenchParams::MIN_LOG_NUM_GATES; +constexpr size_t MAX_LOG_NUM_GATES = bench_utils::BenchParams::MAX_LOG_NUM_GATES; // Number of times to repeat each benchmark -constexpr size_t NUM_REPETITIONS = 1; +constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** * @brief Benchmark: Construction of a Standard proof for a circuit determined by the provided circuit function diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index ba076f3db8..c6317f1640 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -25,10 +25,10 @@ namespace ultra_honk_bench { using UltraHonk = proof_system::honk::UltraHonkComposer; // Number of times to perform operation of interest in the benchmark circuits, e.g. # of hashes to perform -constexpr size_t MIN_NUM_ITERATIONS = 10; -constexpr size_t MAX_NUM_ITERATIONS = 10; +constexpr size_t MIN_NUM_ITERATIONS = bench_utils::BenchParams::MIN_NUM_ITERATIONS; +constexpr size_t MAX_NUM_ITERATIONS = bench_utils::BenchParams::MAX_NUM_ITERATIONS; // Number of times to repeat each benchmark -constexpr size_t NUM_REPETITIONS = 1; +constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided text circuit function @@ -44,7 +44,6 @@ void construct_proof(State& state, void (*test_circuit_function)(Composer&, size test_circuit_function(composer, num_iterations); auto ext_prover = composer.create_prover(); state.ResumeTiming(); - info("composer.num_gates = ", composer.num_gates); // Construct proof auto proof = ext_prover.construct_proof(); @@ -54,14 +53,16 @@ void construct_proof(State& state, void (*test_circuit_function)(Composer&, size BENCHMARK_CAPTURE(construct_proof, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -// BENCHMARK_CAPTURE(construct_proof, keccak, &generate_keccak_test_circuit) -// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) -// ->Repetitions(NUM_REPETITIONS); -// BENCHMARK_CAPTURE(construct_proof, ecdsa_verification, &generate_ecdsa_verification_test_circuit) -// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) -// ->Repetitions(NUM_REPETITIONS); -// BENCHMARK_CAPTURE(construct_proof, merkle_membership, &generate_merkle_membership_test_circuit) -// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) -// ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof, keccak, &bench_utils::generate_keccak_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof, + ecdsa_verification, + &bench_utils::generate_ecdsa_verification_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof, merkle_membership, &bench_utils::generate_merkle_membership_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); } // namespace ultra_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp index fe6a18fd15..c8e047fedd 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp @@ -27,10 +27,10 @@ namespace ultra_plonk_bench { using UltraPlonk = proof_system::plonk::UltraPlonkComposer; // Number of times to perform operation of interest in the benchmark circuits, e.g. # of hashes to perform -constexpr size_t MIN_NUM_ITERATIONS = 10; -constexpr size_t MAX_NUM_ITERATIONS = 10; +constexpr size_t MIN_NUM_ITERATIONS = bench_utils::BenchParams::MIN_NUM_ITERATIONS; +constexpr size_t MAX_NUM_ITERATIONS = bench_utils::BenchParams::MAX_NUM_ITERATIONS; // Number of times to repeat each benchmark -constexpr size_t NUM_REPETITIONS = 1; +constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided text circuit function @@ -46,7 +46,6 @@ void construct_proof(State& state, void (*test_circuit_function)(Composer&, size test_circuit_function(composer, num_iterations); auto ext_prover = composer.create_prover(); state.ResumeTiming(); - info("composer.num_gates = ", composer.num_gates); // Construct proof auto proof = ext_prover.construct_proof(); @@ -56,14 +55,16 @@ void construct_proof(State& state, void (*test_circuit_function)(Composer&, size BENCHMARK_CAPTURE(construct_proof, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -// BENCHMARK_CAPTURE(construct_proof, keccak, &generate_keccak_test_circuit) -// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) -// ->Repetitions(NUM_REPETITIONS); -// BENCHMARK_CAPTURE(construct_proof, ecdsa_verification, &generate_ecdsa_verification_test_circuit) -// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) -// ->Repetitions(NUM_REPETITIONS); -// BENCHMARK_CAPTURE(construct_proof, merkle_membership, &generate_merkle_membership_test_circuit) -// ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) -// ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof, keccak, &bench_utils::generate_keccak_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof, + ecdsa_verification, + &bench_utils::generate_ecdsa_verification_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof, merkle_membership, &bench_utils::generate_merkle_membership_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); } // namespace ultra_plonk_bench \ No newline at end of file From fbebb3b91c4a3cf4fcc396bc9cdf4e05d7a06a55 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 6 Jun 2023 16:09:36 +0000 Subject: [PATCH 03/24] rename and cleanup cmake --- .../benchmark/honk_bench/CMakeLists.txt | 72 ++++--------------- ...ch.sh => compare_honk_branch_vs_master.sh} | 14 ++-- ...h.sh => compare_honk_to_plonk_standard.sh} | 0 ...ench.sh => compare_honk_to_plonk_ultra.sh} | 0 .../honk_bench/standard_honk.bench.cpp | 20 ------ .../honk_bench/standard_plonk.bench.cpp | 20 ------ .../benchmark/honk_bench/ultra_honk.bench.cpp | 18 ----- .../honk_bench/ultra_plonk.bench.cpp | 20 ------ 8 files changed, 22 insertions(+), 142 deletions(-) rename cpp/src/barretenberg/benchmark/honk_bench/{compare_honk_bench.sh => compare_honk_branch_vs_master.sh} (79%) rename cpp/src/barretenberg/benchmark/honk_bench/{compare_standard_bench.sh => compare_honk_to_plonk_standard.sh} (100%) rename cpp/src/barretenberg/benchmark/honk_bench/{compare_ultra_bench.sh => compare_honk_to_plonk_ultra.sh} (100%) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index 4251be3d3a..4953c39d72 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -1,66 +1,24 @@ -add_executable(standard_honk_bench main.bench.cpp standard_honk.bench.cpp) -add_executable(standard_plonk_bench main.bench.cpp standard_plonk.bench.cpp) -add_executable(ultra_honk_bench main.bench.cpp ultra_honk.bench.cpp) -add_executable(ultra_plonk_bench main.bench.cpp ultra_plonk.bench.cpp) - -target_link_libraries( - standard_honk_bench - stdlib_primitives - common - stdlib_sha256 - stdlib_keccak - stdlib_merkle_tree - env - benchmark::benchmark +# Each source represents a separate benchmark suite +set(BENCHMARK_SOURCES +standard_honk.bench.cpp +standard_plonk.bench.cpp +ultra_honk.bench.cpp +ultra_plonk.bench.cpp ) -target_link_libraries( - standard_plonk_bench +# Required libraries for benchmark suites +set(LINKED_LIBRARIES stdlib_primitives stdlib_sha256 stdlib_keccak stdlib_merkle_tree - env benchmark::benchmark ) -target_link_libraries( - ultra_honk_bench - stdlib_primitives - stdlib_sha256 - stdlib_keccak - stdlib_merkle_tree - env - benchmark::benchmark -) - -target_link_libraries( - ultra_plonk_bench - stdlib_primitives - stdlib_sha256 - stdlib_keccak - stdlib_merkle_tree - env - benchmark::benchmark -) - -add_custom_target( - run_standard_honk_bench - COMMAND standard_honk_bench - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -) -add_custom_target( - run_standard_plonk_bench - COMMAND standard_plonk_bench - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -) -add_custom_target( - run_ultra_honk_bench - COMMAND ultra_honk_bench - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -) -add_custom_target( - run_ultra_plonk_bench - COMMAND ultra_plonk_bench - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -) \ No newline at end of file +# Add executable and custom target for each suite, e.g. standard_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/honk_bench/compare_honk_bench.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_master.sh similarity index 79% rename from cpp/src/barretenberg/benchmark/honk_bench/compare_honk_bench.sh rename to cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_master.sh index 95cdbb8ed6..f76b70126a 100755 --- a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_bench.sh +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_master.sh @@ -1,6 +1,6 @@ #!/bin/bash -# This script is used to compare the results of honk_bench between baseline (master) and +# This script is used to compare the honk benchmarks between baseline (master) and # the branch from which the script is run. Simply check out the branch of interest, ensure # it is up to date with local master, and run the script. @@ -19,8 +19,8 @@ pip3 install -r $BUILD_DIR/_deps/benchmark-src/requirements.txt cd $BASE_DIR mkdir $BENCH_RESULTS_DIR -# Checkout master, run honk_bench, save results in json format -echo -e '\nConfiguring and building honk_bench in master branch..' +# Checkout master, run benchmarks, save results in json format +echo -e '\nConfiguring and building benchmarks in master branch..' git checkout master > /dev/null rm -rf $BUILD_DIR cmake --preset bench > /dev/null && cmake --build --preset bench --target honk_bench > /dev/null @@ -29,15 +29,15 @@ MASTER_HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench_results_master.json" echo -e '\nRunning honk_bench in master..' bin/honk_bench --benchmark_format=json > $MASTER_HONK_BENCH_RESULTS -# Checkout working branch (-), run honk_bench, save results in json format -echo -e '\nConfiguring and building honk_bench in current feature branch..' +# Checkout working branch (-), run benchmarks, save results in json format +echo -e '\nConfiguring and building benchmarks in current feature branch..' git checkout - rm -rf $BUILD_DIR -cmake --preset bench > /dev/null && cmake --build --preset bench --target honk_bench > /dev/null +cmake --preset bench > /dev/null && cmake --build --preset bench --target honk_bench cd build-bench BRANCH_HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench_results_branch.json" echo -e '\nRunning honk_bench in feature branch..' -bin/honk_bench --benchmark_format=json > $BRANCH_HONK_BENCH_RESULTS +bin/ultra_honk_bench --benchmark_format=json > $BRANCH_HONK_BENCH_RESULTS # Call compare.py on the results (json) to get high level statistics. # See docs at https://github.com/google/benchmark/blob/main/docs/tools.md for more details. diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_standard_bench.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_standard.sh similarity index 100% rename from cpp/src/barretenberg/benchmark/honk_bench/compare_standard_bench.sh rename to cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_standard.sh diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_ultra_bench.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_ultra.sh similarity index 100% rename from cpp/src/barretenberg/benchmark/honk_bench/compare_ultra_bench.sh rename to cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_ultra.sh diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp index 993523c327..d0cde9a797 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp @@ -1,23 +1,3 @@ -#include "barretenberg/crypto/ecdsa/ecdsa.hpp" -#include "barretenberg/ecc/curves/bn254/fr.hpp" -#include "barretenberg/honk/proof_system/ultra_prover.hpp" -#include "barretenberg/honk/proof_system/ultra_verifier.hpp" -#include -#include -#include "barretenberg/honk/composer/standard_honk_composer.hpp" -#include "barretenberg/plonk/composer/standard_plonk_composer.hpp" -#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" -#include "barretenberg/stdlib/hash/keccak/keccak.hpp" -#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" -#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" -#include "barretenberg/stdlib/hash/sha256/sha256.hpp" -#include "barretenberg/stdlib/primitives/bool/bool.hpp" -#include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/primitives/witness/witness.hpp" -#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" -#include "barretenberg/stdlib/merkle_tree/membership.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" #include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" using namespace benchmark; diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp index e168edd295..b52d2e315f 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp @@ -1,23 +1,3 @@ -#include "barretenberg/crypto/ecdsa/ecdsa.hpp" -#include "barretenberg/ecc/curves/bn254/fr.hpp" -#include "barretenberg/honk/proof_system/ultra_prover.hpp" -#include "barretenberg/honk/proof_system/ultra_verifier.hpp" -#include -#include -#include "barretenberg/honk/composer/standard_honk_composer.hpp" -#include "barretenberg/plonk/composer/standard_plonk_composer.hpp" -#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" -#include "barretenberg/stdlib/hash/keccak/keccak.hpp" -#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" -#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" -#include "barretenberg/stdlib/hash/sha256/sha256.hpp" -#include "barretenberg/stdlib/primitives/bool/bool.hpp" -#include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/primitives/witness/witness.hpp" -#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" -#include "barretenberg/stdlib/merkle_tree/membership.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" #include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" using namespace benchmark; diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index c6317f1640..d13d535665 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -1,21 +1,3 @@ -#include "barretenberg/crypto/ecdsa/ecdsa.hpp" -#include "barretenberg/ecc/curves/bn254/fr.hpp" -#include -#include -#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp" -#include "barretenberg/stdlib/primitives/composers/composers.hpp" -#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" -#include "barretenberg/stdlib/hash/keccak/keccak.hpp" -#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" -#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" -#include "barretenberg/stdlib/hash/sha256/sha256.hpp" -#include "barretenberg/stdlib/primitives/bool/bool.hpp" -#include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/primitives/witness/witness.hpp" -#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" -#include "barretenberg/stdlib/merkle_tree/membership.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" #include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" using namespace benchmark; diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp index c8e047fedd..28cf4fd679 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp @@ -1,23 +1,3 @@ -#include "barretenberg/crypto/ecdsa/ecdsa.hpp" -#include "barretenberg/ecc/curves/bn254/fr.hpp" -#include "barretenberg/honk/proof_system/ultra_prover.hpp" -#include "barretenberg/honk/proof_system/ultra_verifier.hpp" -#include -#include -#include "barretenberg/honk/composer/ultra_honk_composer.hpp" -#include "barretenberg/plonk/composer/ultra_plonk_composer.hpp" -#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" -#include "barretenberg/stdlib/hash/keccak/keccak.hpp" -#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" -#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" -#include "barretenberg/stdlib/hash/sha256/sha256.hpp" -#include "barretenberg/stdlib/primitives/bool/bool.hpp" -#include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/primitives/witness/witness.hpp" -#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" -#include "barretenberg/stdlib/merkle_tree/membership.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" -#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" #include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" using namespace benchmark; From 43ed3eecf7b348888d2e7de1edd3579ebbbc90f1 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 6 Jun 2023 16:39:13 +0000 Subject: [PATCH 04/24] updates to master comparison script --- ....sh => compare_honk_branch_vs_baseline.sh} | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) rename cpp/src/barretenberg/benchmark/honk_bench/{compare_honk_branch_vs_master.sh => compare_honk_branch_vs_baseline.sh} (51%) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_master.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh similarity index 51% rename from cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_master.sh rename to cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh index f76b70126a..47add30894 100755 --- a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_master.sh +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh @@ -1,13 +1,17 @@ #!/bin/bash -# This script is used to compare the honk benchmarks between baseline (master) and +# This script is used to compare the honk benchmarks between baseline (default: master) and # the branch from which the script is run. Simply check out the branch of interest, ensure # it is up to date with local master, and run the script. -echo -e '\nComparing Honk benchmarks between master and current branch:' +# Specify the benchmark suite and the "baseline" branch against which to compare +BENCH_TARGET="ultra_honk_bench" +BASELINE_BRANCH="master" + +echo -e "\nComparing $BENCH_TARGET between $BASELINE_BRANCH and current branch:" # Set some directories BASE_DIR="$HOME/barretenberg/cpp" -BUILD_DIR="$BASE_DIR/build-bench" +BUILD_DIR="$BASE_DIR/build-bench" # matches build dir specified in bench preset BENCH_RESULTS_DIR="$BASE_DIR/tmp_bench_results" BENCH_TOOLS_DIR="$BUILD_DIR/_deps/benchmark-src/tools" @@ -15,33 +19,33 @@ BENCH_TOOLS_DIR="$BUILD_DIR/_deps/benchmark-src/tools" # Note: By default, installation will occur in $HOME/.local/bin. pip3 install -r $BUILD_DIR/_deps/benchmark-src/requirements.txt -# Create temporary directory for honk_bench results (json) +# Create temporary directory for benchmark results (json) cd $BASE_DIR mkdir $BENCH_RESULTS_DIR -# Checkout master, run benchmarks, save results in json format -echo -e '\nConfiguring and building benchmarks in master branch..' +# Checkout baseline branch, run benchmarks, save results in json format +echo -e "\nConfiguring and building $BENCH_TARGET in $BASELINE_BRANCH branch..\n" git checkout master > /dev/null rm -rf $BUILD_DIR -cmake --preset bench > /dev/null && cmake --build --preset bench --target honk_bench > /dev/null +cmake --preset bench > /dev/null && cmake --build --preset bench --target $BENCH_TARGET cd build-bench -MASTER_HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench_results_master.json" -echo -e '\nRunning honk_bench in master..' -bin/honk_bench --benchmark_format=json > $MASTER_HONK_BENCH_RESULTS +BASELINE_RESULTS="$BENCH_RESULTS_DIR/results_baseline.json" +echo -e "\nRunning $BENCH_TARGET in master.." +bin/$BENCH_TARGET --benchmark_format=json > $BASELINE_RESULTS # Checkout working branch (-), run benchmarks, save results in json format -echo -e '\nConfiguring and building benchmarks in current feature branch..' +echo -e "\nConfiguring and building $BENCH_TARGET in current feature branch..\n" git checkout - rm -rf $BUILD_DIR -cmake --preset bench > /dev/null && cmake --build --preset bench --target honk_bench +cmake --preset bench > /dev/null && cmake --build --preset bench --target $BENCH_TARGET cd build-bench -BRANCH_HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench_results_branch.json" -echo -e '\nRunning honk_bench in feature branch..' -bin/ultra_honk_bench --benchmark_format=json > $BRANCH_HONK_BENCH_RESULTS +BRANCH_RESULTS="$BENCH_RESULTS_DIR/results_branch.json" +echo -e "\nRunning $BENCH_TARGET in feature branch.." +bin/$BENCH_TARGET --benchmark_format=json > $BRANCH_RESULTS # Call compare.py on the results (json) to get high level statistics. # See docs at https://github.com/google/benchmark/blob/main/docs/tools.md for more details. -$BENCH_TOOLS_DIR/compare.py benchmarks $MASTER_HONK_BENCH_RESULTS $BRANCH_HONK_BENCH_RESULTS +$BENCH_TOOLS_DIR/compare.py benchmarks $BASELINE_RESULTS $BRANCH_RESULTS # Delete the temporary results directory and its contents -rm -r $BENCH_RESULTS_DIR \ No newline at end of file +rm -r $BENCH_RESULTS_DIR From d7b9c9e27d8d49fc5075a30d2d4ac0d8777f58bd Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 8 Jun 2023 18:19:33 +0000 Subject: [PATCH 05/24] adding basic workflow to run bench --- .github/workflows/benchmarks.yml | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/benchmarks.yml diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 0000000000..64a99a41d1 --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,60 @@ +name: Barretenberg Benchmarks + +# For now, run basically whenever anything happens in a PR +on: + pull_request: + types: ["labeled", "opened", "synchronize", "reopened"] + +# This will cancel previous runs when a branch or PR is updated +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + bberg-bench: + name: Barretenberg Benchmarks + runs-on: ubuntu-latest # run in linux environment + + steps: + + - name: Checkout barretenberg + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} # checkout HEAD of triggering branch + token: ${{ secrets.GITHUB_TOKEN }} + + # Adding some credentials to avoid complaints from git + - name: Configure git + run: | + git config user.name ledwards2225 + git config user.email l.edwards.d@gmail.com + + # Only run in Linux environment for now + - name: Setup Linux environment + run: | + sudo apt update + sudo apt install libomp-dev cmake ninja-build + + - name: Download SRS elements + working-directory: cpp/srs_db + run: ./download_ignition.sh 3 # only download first 4 transcript files + + - name: Build Honk benchmarks + working-directory: cpp + run: | + cmake --preset bench + cmake --build --preset bench --target ultra_honk_bench + + - name: Run Honk benchmarks + working-directory: cpp/build-bench + run: | + bin/ultra_honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json + + # # Commit benchmark results json to the branch + # - name: Commit result + # working-directory: cpp + # run: | + # git add src/barretenberg/benchmark/honk_bench/bench_results.json + # git commit -m "add bench results" + # git push + \ No newline at end of file From 8b3ee41c3ff2fd51987da8fb718438ea0469a50c Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 8 Jun 2023 18:32:51 +0000 Subject: [PATCH 06/24] cache bench result --- .github/workflows/benchmarks.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 64a99a41d1..a7f029546f 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -50,6 +50,21 @@ jobs: run: | bin/ultra_honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json + # + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + name: C++ Benchmark + tool: 'googlecpp' + output-file-path: examples/cpp/benchmark_result.json + # github-token: ${{ secrets.GITHUB_TOKEN }} + # auto-push: true + # # Show alert with commit comment on detecting possible performance regression + # alert-threshold: '200%' + # comment-on-alert: true + # fail-on-alert: true + # alert-comment-cc-users: '@ktrz' + # # Commit benchmark results json to the branch # - name: Commit result # working-directory: cpp From 17291cee52178c4387ce2eb4dcf7543a3b3960e0 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 8 Jun 2023 18:51:17 +0000 Subject: [PATCH 07/24] attempt pages update --- .github/workflows/benchmarks.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index a7f029546f..2fa43f9753 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -56,9 +56,13 @@ jobs: with: name: C++ Benchmark tool: 'googlecpp' - output-file-path: examples/cpp/benchmark_result.json - # github-token: ${{ secrets.GITHUB_TOKEN }} - # auto-push: true + output-file-path: src/barretenberg/benchmark/honk_bench/bench_results.json + # Access token to deploy GitHub Pages branch + github-token: ${{ secrets.GITHUB_TOKEN }} + # Push and deploy GitHub pages branch automatically + auto-push: true + # Enable Job Summary for PRs + summary-always: true # # Show alert with commit comment on detecting possible performance regression # alert-threshold: '200%' # comment-on-alert: true From cc9c3f3397fc5e84d1e34c9834cd7506e79d98b5 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 8 Jun 2023 19:17:06 +0000 Subject: [PATCH 08/24] test --- .github/workflows/benchmarks.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 2fa43f9753..343b4ac6b0 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -50,6 +50,15 @@ jobs: run: | bin/ultra_honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json + # Commit benchmark results json to the branch + - name: Commit result + working-directory: cpp + run: | + pwd + git add src/barretenberg/benchmark/honk_bench/bench_results.json + git commit -m "add bench results" + git push + # - name: Store benchmark result uses: benchmark-action/github-action-benchmark@v1 @@ -69,11 +78,4 @@ jobs: # fail-on-alert: true # alert-comment-cc-users: '@ktrz' - # # Commit benchmark results json to the branch - # - name: Commit result - # working-directory: cpp - # run: | - # git add src/barretenberg/benchmark/honk_bench/bench_results.json - # git commit -m "add bench results" - # git push \ No newline at end of file From 300628429a10e92815b08da1397ef33a879e5144 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 8 Jun 2023 19:51:40 +0000 Subject: [PATCH 09/24] add check for result file --- .github/workflows/benchmarks.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 343b4ac6b0..0685100e87 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -58,6 +58,14 @@ jobs: git add src/barretenberg/benchmark/honk_bench/bench_results.json git commit -m "add bench results" git push + + # Check for existence of bench results + - name: Check bench result file exists + working-directory: cpp + run: | + pwd + cd src/barretenberg/benchmark/honk_bench + ls # - name: Store benchmark result From 30b508dab4d311e438fd492d1c8c898308d89f1d Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 8 Jun 2023 19:26:17 +0000 Subject: [PATCH 10/24] add bench results --- .../benchmark/honk_bench/bench_results.json | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/bench_results.json diff --git a/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json b/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json new file mode 100644 index 0000000000..fcd6d38143 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json @@ -0,0 +1,96 @@ +{ + "context": { + "date": "2023-06-08T19:24:52+00:00", + "host_name": "fv-az583-714", + "executable": "bin/ultra_honk_bench", + "num_cpus": 2, + "mhz_per_cpu": 2793, + "cpu_scaling_enabled": false, + "caches": [ + { + "type": "Data", + "level": 1, + "size": 49152, + "num_sharing": 1 + }, + { + "type": "Instruction", + "level": 1, + "size": 32768, + "num_sharing": 1 + }, + { + "type": "Unified", + "level": 2, + "size": 1310720, + "num_sharing": 1 + }, + { + "type": "Unified", + "level": 3, + "size": 50331648, + "num_sharing": 2 + } + ], + "load_avg": [2.37744,2.12939,1.06592], + "library_build_type": "release" + }, + "benchmarks": [ + { + "name": "construct_proof/sha256/10/repeats:1", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "construct_proof/sha256/10/repeats:1", + "run_type": "iteration", + "repetitions": 1, + "repetition_index": 0, + "threads": 1, + "iterations": 1, + "real_time": 1.3003723924000042e+10, + "cpu_time": 1.0834760399999998e+10, + "time_unit": "ns" + }, + { + "name": "construct_proof/keccak/10/repeats:1", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof/keccak/10/repeats:1", + "run_type": "iteration", + "repetitions": 1, + "repetition_index": 0, + "threads": 1, + "iterations": 1, + "real_time": 2.1656035516999966e+10, + "cpu_time": 1.9191273799999996e+10, + "time_unit": "ns" + }, + { + "name": "construct_proof/ecdsa_verification/10/repeats:1", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "construct_proof/ecdsa_verification/10/repeats:1", + "run_type": "iteration", + "repetitions": 1, + "repetition_index": 0, + "threads": 1, + "iterations": 1, + "real_time": 3.8913263483999969e+10, + "cpu_time": 3.6777872500000000e+10, + "time_unit": "ns" + }, + { + "name": "construct_proof/merkle_membership/10/repeats:1", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof/merkle_membership/10/repeats:1", + "run_type": "iteration", + "repetitions": 1, + "repetition_index": 0, + "threads": 1, + "iterations": 1, + "real_time": 4.3371778289999838e+09, + "cpu_time": 2.5496391000000072e+09, + "time_unit": "ns" + } + ] +} From e0ea7eea55dce24fbaffe793d5a49f24a3b719cf Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 8 Jun 2023 20:09:43 +0000 Subject: [PATCH 11/24] is committing to the results the problem --- .github/workflows/benchmarks.yml | 16 ++-- .../benchmark/honk_bench/bench_results.json | 96 ------------------- 2 files changed, 8 insertions(+), 104 deletions(-) delete mode 100644 cpp/src/barretenberg/benchmark/honk_bench/bench_results.json diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 0685100e87..b61e031bae 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -50,14 +50,14 @@ jobs: run: | bin/ultra_honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json - # Commit benchmark results json to the branch - - name: Commit result - working-directory: cpp - run: | - pwd - git add src/barretenberg/benchmark/honk_bench/bench_results.json - git commit -m "add bench results" - git push + # # Commit benchmark results json to the branch + # - name: Commit result + # working-directory: cpp + # run: | + # pwd + # git add src/barretenberg/benchmark/honk_bench/bench_results.json + # git commit -m "add bench results" + # git push # Check for existence of bench results - name: Check bench result file exists diff --git a/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json b/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json deleted file mode 100644 index fcd6d38143..0000000000 --- a/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "context": { - "date": "2023-06-08T19:24:52+00:00", - "host_name": "fv-az583-714", - "executable": "bin/ultra_honk_bench", - "num_cpus": 2, - "mhz_per_cpu": 2793, - "cpu_scaling_enabled": false, - "caches": [ - { - "type": "Data", - "level": 1, - "size": 49152, - "num_sharing": 1 - }, - { - "type": "Instruction", - "level": 1, - "size": 32768, - "num_sharing": 1 - }, - { - "type": "Unified", - "level": 2, - "size": 1310720, - "num_sharing": 1 - }, - { - "type": "Unified", - "level": 3, - "size": 50331648, - "num_sharing": 2 - } - ], - "load_avg": [2.37744,2.12939,1.06592], - "library_build_type": "release" - }, - "benchmarks": [ - { - "name": "construct_proof/sha256/10/repeats:1", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "construct_proof/sha256/10/repeats:1", - "run_type": "iteration", - "repetitions": 1, - "repetition_index": 0, - "threads": 1, - "iterations": 1, - "real_time": 1.3003723924000042e+10, - "cpu_time": 1.0834760399999998e+10, - "time_unit": "ns" - }, - { - "name": "construct_proof/keccak/10/repeats:1", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof/keccak/10/repeats:1", - "run_type": "iteration", - "repetitions": 1, - "repetition_index": 0, - "threads": 1, - "iterations": 1, - "real_time": 2.1656035516999966e+10, - "cpu_time": 1.9191273799999996e+10, - "time_unit": "ns" - }, - { - "name": "construct_proof/ecdsa_verification/10/repeats:1", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "construct_proof/ecdsa_verification/10/repeats:1", - "run_type": "iteration", - "repetitions": 1, - "repetition_index": 0, - "threads": 1, - "iterations": 1, - "real_time": 3.8913263483999969e+10, - "cpu_time": 3.6777872500000000e+10, - "time_unit": "ns" - }, - { - "name": "construct_proof/merkle_membership/10/repeats:1", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof/merkle_membership/10/repeats:1", - "run_type": "iteration", - "repetitions": 1, - "repetition_index": 0, - "threads": 1, - "iterations": 1, - "real_time": 4.3371778289999838e+09, - "cpu_time": 2.5496391000000072e+09, - "time_unit": "ns" - } - ] -} From a780d9a06bd464c516b600a5cb57f34181a2f267 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 9 Jun 2023 16:51:52 +0000 Subject: [PATCH 12/24] fix path --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index b61e031bae..ae9cd0a582 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -73,7 +73,7 @@ jobs: with: name: C++ Benchmark tool: 'googlecpp' - output-file-path: src/barretenberg/benchmark/honk_bench/bench_results.json + output-file-path: cpp/src/barretenberg/benchmark/honk_bench/bench_results.json # Access token to deploy GitHub Pages branch github-token: ${{ secrets.GITHUB_TOKEN }} # Push and deploy GitHub pages branch automatically From 8392e9c158326107cfdabd706b1763deaff36b9c Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 9 Jun 2023 17:15:06 +0000 Subject: [PATCH 13/24] update and remove debug code from yml --- .github/workflows/benchmarks.yml | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index ae9cd0a582..85f073c0e4 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -49,23 +49,6 @@ jobs: working-directory: cpp/build-bench run: | bin/ultra_honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json - - # # Commit benchmark results json to the branch - # - name: Commit result - # working-directory: cpp - # run: | - # pwd - # git add src/barretenberg/benchmark/honk_bench/bench_results.json - # git commit -m "add bench results" - # git push - - # Check for existence of bench results - - name: Check bench result file exists - working-directory: cpp - run: | - pwd - cd src/barretenberg/benchmark/honk_bench - ls # - name: Store benchmark result @@ -80,10 +63,10 @@ jobs: auto-push: true # Enable Job Summary for PRs summary-always: true - # # Show alert with commit comment on detecting possible performance regression - # alert-threshold: '200%' - # comment-on-alert: true - # fail-on-alert: true - # alert-comment-cc-users: '@ktrz' + # Show alert with commit comment on detecting possible performance regression + alert-threshold: '120%' # alert if bench result is 1.2x worse + comment-on-alert: true + fail-on-alert: true + alert-comment-cc-users: '@ledwards2225' \ No newline at end of file From de6221214ff05b75bfbcfb4995416cac4abdcc63 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 12 Jun 2023 18:17:46 +0000 Subject: [PATCH 14/24] test not git cred and multiple reps --- .github/workflows/benchmarks.yml | 16 +++++++++------- .../benchmark/honk_bench/benchmark_utilities.hpp | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 85f073c0e4..bcb1e4f245 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -23,11 +23,11 @@ jobs: ref: ${{ github.head_ref }} # checkout HEAD of triggering branch token: ${{ secrets.GITHUB_TOKEN }} - # Adding some credentials to avoid complaints from git - - name: Configure git - run: | - git config user.name ledwards2225 - git config user.email l.edwards.d@gmail.com + # # Adding some credentials to avoid complaints from git + # - name: Configure git + # run: | + # git config user.name ledwards2225 + # git config user.email l.edwards.d@gmail.com # Only run in Linux environment for now - name: Setup Linux environment @@ -50,7 +50,9 @@ jobs: run: | bin/ultra_honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json - # + # Utilize github-action-benchmark to automatically update the plots at + # https://aztecprotocol.github.io/barretenberg/dev/bench/ with new benchmark data. + # This also creates an alert if benchmarks exceed the threshold specified below. - name: Store benchmark result uses: benchmark-action/github-action-benchmark@v1 with: @@ -66,7 +68,7 @@ jobs: # Show alert with commit comment on detecting possible performance regression alert-threshold: '120%' # alert if bench result is 1.2x worse comment-on-alert: true - fail-on-alert: true + fail-on-alert: false alert-comment-cc-users: '@ledwards2225' \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 23c8ad33bd..2893e71e1f 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -32,7 +32,7 @@ struct BenchParams { static constexpr size_t MIN_LOG_NUM_GATES = 16; static constexpr size_t MAX_LOG_NUM_GATES = 16; - static constexpr size_t NUM_REPETITIONS = 1; + static constexpr size_t NUM_REPETITIONS = 2; }; /** From b0876578ce5f2422e9fa8f422919841d67e7530b Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 12 Jun 2023 19:13:07 +0000 Subject: [PATCH 15/24] revert to single repetition --- .github/workflows/benchmarks.yml | 8 +------- .../benchmark/honk_bench/benchmark_utilities.hpp | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index bcb1e4f245..ba86e785b4 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -23,13 +23,7 @@ jobs: ref: ${{ github.head_ref }} # checkout HEAD of triggering branch token: ${{ secrets.GITHUB_TOKEN }} - # # Adding some credentials to avoid complaints from git - # - name: Configure git - # run: | - # git config user.name ledwards2225 - # git config user.email l.edwards.d@gmail.com - - # Only run in Linux environment for now + # Only run in Linux environment for now - name: Setup Linux environment run: | sudo apt update diff --git a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 2893e71e1f..23c8ad33bd 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -32,7 +32,7 @@ struct BenchParams { static constexpr size_t MIN_LOG_NUM_GATES = 16; static constexpr size_t MAX_LOG_NUM_GATES = 16; - static constexpr size_t NUM_REPETITIONS = 2; + static constexpr size_t NUM_REPETITIONS = 1; }; /** From bb50c37ac2a34ac9dcd4dd06cc7ad2ef756b374a Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 12 Jun 2023 22:09:19 +0000 Subject: [PATCH 16/24] attempt to fix crs issue --- .../benchmark/honk_bench/CMakeLists.txt | 2 +- .../honk_bench/benchmark_utilities.hpp | 56 +++++++++++++++++++ .../honk_bench/standard_honk.bench.cpp | 16 +----- .../honk_bench/standard_plonk.bench.cpp | 16 +----- .../benchmark/honk_bench/ultra_honk.bench.cpp | 29 ++++------ .../honk_bench/ultra_plonk.bench.cpp | 28 +++------- 6 files changed, 80 insertions(+), 67 deletions(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index 4953c39d72..2af20945cc 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -18,7 +18,7 @@ set(LINKED_LIBRARIES # Add executable and custom target for each suite, e.g. standard_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}) + add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE} benchmark_utilities.hpp) 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/honk_bench/benchmark_utilities.hpp b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 23c8ad33bd..8e15858789 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -165,4 +165,60 @@ template void generate_merkle_membership_test_circuit(Compos } } +/** + * @brief Performs proof constuction for benchmarks based on a provided circuit function + * + * @details This function assumes state.range refers to num_gates which is the size of the underlying circuit + * + * @tparam Composer + * @param state + * @param test_circuit_function + */ +template +void construct_proof_with_specified_num_gates(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +{ + barretenberg::srs::init_crs_factory("../srs_db/ignition"); + auto num_gates = static_cast(1 << (size_t)state.range(0)); + for (auto _ : state) { + // Constuct circuit and prover; don't include this part in measurement + state.PauseTiming(); + auto composer = Composer(); + test_circuit_function(composer, num_gates); + auto ext_prover = composer.create_prover(); + state.ResumeTiming(); + + // Construct proof + auto proof = ext_prover.construct_proof(); + } +} + +/** + * @brief Performs proof constuction for benchmarks based on a provided circuit function + * + * @details This function assumes state.range refers to num_iterations which is the number of times to perform a given + * basic operation in the circuit, e.g. number of hashes + * + * @tparam Composer + * @param state + * @param test_circuit_function + */ +template +void construct_proof_with_specified_num_iterations(State& state, + void (*test_circuit_function)(Composer&, size_t)) noexcept +{ + barretenberg::srs::init_crs_factory("../srs_db/ignition"); + auto num_iterations = static_cast(state.range(0)); + for (auto _ : state) { + // Constuct circuit and prover; don't include this part in measurement + state.PauseTiming(); + auto composer = Composer(); + test_circuit_function(composer, num_iterations); + auto ext_prover = composer.create_prover(); + state.ResumeTiming(); + + // Construct proof + auto proof = ext_prover.construct_proof(); + } +} + } // namespace bench_utils \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp index d0cde9a797..ac813deae8 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp @@ -15,21 +15,9 @@ constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** * @brief Benchmark: Construction of a Standard proof for a circuit determined by the provided circuit function */ -template -void construct_proof_standard(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +void construct_proof_standard(State& state, void (*test_circuit_function)(StandardHonk&, size_t)) noexcept { - auto num_gates = static_cast(1 << (size_t)state.range(0)); - for (auto _ : state) { - // Constuct circuit and prover; don't include this part in measurement - state.PauseTiming(); - auto composer = Composer(); - test_circuit_function(composer, num_gates); - auto ext_prover = composer.create_prover(); - state.ResumeTiming(); - - // Construct proof - auto proof = ext_prover.construct_proof(); - } + bench_utils::construct_proof_with_specified_num_gates(state, test_circuit_function); } BENCHMARK_CAPTURE(construct_proof_standard, arithmetic, &bench_utils::generate_basic_arithmetic_circuit) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp index b52d2e315f..74d085e4ef 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp @@ -15,21 +15,9 @@ constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** * @brief Benchmark: Construction of a Standard proof for a circuit determined by the provided circuit function */ -template -void construct_proof_standard(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +void construct_proof_standard(State& state, void (*test_circuit_function)(StandardPlonk&, size_t)) noexcept { - auto num_gates = static_cast(1 << (size_t)state.range(0)); - for (auto _ : state) { - // Constuct circuit and prover; don't include this part in measurement - state.PauseTiming(); - auto composer = Composer(); - test_circuit_function(composer, num_gates); - auto ext_prover = composer.create_prover(); - state.ResumeTiming(); - - // Construct proof - auto proof = ext_prover.construct_proof(); - } + bench_utils::construct_proof_with_specified_num_gates(state, test_circuit_function); } BENCHMARK_CAPTURE(construct_proof_standard, arithmetic, &bench_utils::generate_basic_arithmetic_circuit) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index d13d535665..81a42e6165 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -13,37 +13,28 @@ constexpr size_t MAX_NUM_ITERATIONS = bench_utils::BenchParams::MAX_NUM_ITERATIO constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** - * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided text circuit function + * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided circuit function */ -template -void construct_proof(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraHonk&, size_t)) noexcept { - auto num_iterations = static_cast(state.range(0)); - for (auto _ : state) { - // Constuct circuit and prover; don't include this part in measurement - state.PauseTiming(); - auto composer = Composer(); - test_circuit_function(composer, num_iterations); - auto ext_prover = composer.create_prover(); - state.ResumeTiming(); - - // Construct proof - auto proof = ext_prover.construct_proof(); - } + bench_utils::construct_proof_with_specified_num_iterations(state, test_circuit_function); } -BENCHMARK_CAPTURE(construct_proof, sha256, &bench_utils::generate_sha256_test_circuit) +using namespace bench_utils; +BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof, keccak, &bench_utils::generate_keccak_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &bench_utils::generate_keccak_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof, +BENCHMARK_CAPTURE(construct_proof_ultra, ecdsa_verification, &bench_utils::generate_ecdsa_verification_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof, merkle_membership, &bench_utils::generate_merkle_membership_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultra, + merkle_membership, + &bench_utils::generate_merkle_membership_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp index 28cf4fd679..c1e376acc7 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp @@ -13,37 +13,27 @@ constexpr size_t MAX_NUM_ITERATIONS = bench_utils::BenchParams::MAX_NUM_ITERATIO constexpr size_t NUM_REPETITIONS = bench_utils::BenchParams::NUM_REPETITIONS; /** - * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided text circuit function + * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided circuit function */ -template -void construct_proof(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept +void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraPlonk&, size_t)) noexcept { - auto num_iterations = static_cast(state.range(0)); - for (auto _ : state) { - // Constuct circuit and prover; don't include this part in measurement - state.PauseTiming(); - auto composer = Composer(); - test_circuit_function(composer, num_iterations); - auto ext_prover = composer.create_prover(); - state.ResumeTiming(); - - // Construct proof - auto proof = ext_prover.construct_proof(); - } + bench_utils::construct_proof_with_specified_num_iterations(state, test_circuit_function); } -BENCHMARK_CAPTURE(construct_proof, sha256, &bench_utils::generate_sha256_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof, keccak, &bench_utils::generate_keccak_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &bench_utils::generate_keccak_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof, +BENCHMARK_CAPTURE(construct_proof_ultra, ecdsa_verification, &bench_utils::generate_ecdsa_verification_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); -BENCHMARK_CAPTURE(construct_proof, merkle_membership, &bench_utils::generate_merkle_membership_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultra, + merkle_membership, + &bench_utils::generate_merkle_membership_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS); From c6577a18ba28c6aefa8d011e066a39d3ca47f9d4 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 14 Jun 2023 03:39:40 +0000 Subject: [PATCH 17/24] on push to branch or master --- .github/workflows/benchmarks.yml | 9 +++++++-- .../benchmark/honk_bench/standard_honk.bench.cpp | 3 ++- .../benchmark/honk_bench/standard_plonk.bench.cpp | 3 ++- .../benchmark/honk_bench/ultra_honk.bench.cpp | 12 ++++++++---- .../benchmark/honk_bench/ultra_plonk.bench.cpp | 12 ++++++++---- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index ba86e785b4..bfef80dcaf 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -2,8 +2,13 @@ name: Barretenberg Benchmarks # For now, run basically whenever anything happens in a PR on: - pull_request: - types: ["labeled", "opened", "synchronize", "reopened"] + push: + branches: + - master + - lde/ultra_bench_update +# on: +# pull_request: +# types: ["labeled", "opened", "synchronize", "reopened"] # This will cancel previous runs when a branch or PR is updated concurrency: diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp index ac813deae8..c88d80292d 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_honk.bench.cpp @@ -22,6 +22,7 @@ void construct_proof_standard(State& state, void (*test_circuit_function)(Standa BENCHMARK_CAPTURE(construct_proof_standard, arithmetic, &bench_utils::generate_basic_arithmetic_circuit) ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); } // namespace standard_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp index 74d085e4ef..106fd00f19 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/standard_plonk.bench.cpp @@ -22,6 +22,7 @@ void construct_proof_standard(State& state, void (*test_circuit_function)(Standa BENCHMARK_CAPTURE(construct_proof_standard, arithmetic, &bench_utils::generate_basic_arithmetic_circuit) ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); } // namespace standard_plonk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index 81a42e6165..168be9c221 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -23,19 +23,23 @@ void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraHonk using namespace bench_utils; BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &bench_utils::generate_keccak_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); BENCHMARK_CAPTURE(construct_proof_ultra, ecdsa_verification, &bench_utils::generate_ecdsa_verification_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); BENCHMARK_CAPTURE(construct_proof_ultra, merkle_membership, &bench_utils::generate_merkle_membership_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); } // namespace ultra_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp index c1e376acc7..064d5ef204 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_plonk.bench.cpp @@ -22,19 +22,23 @@ void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraPlon BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &bench_utils::generate_keccak_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); BENCHMARK_CAPTURE(construct_proof_ultra, ecdsa_verification, &bench_utils::generate_ecdsa_verification_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); BENCHMARK_CAPTURE(construct_proof_ultra, merkle_membership, &bench_utils::generate_merkle_membership_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) - ->Repetitions(NUM_REPETITIONS); + ->Repetitions(NUM_REPETITIONS) + ->Unit(::benchmark::kSecond); } // namespace ultra_plonk_bench \ No newline at end of file From c850a32f5a518faffdc702d886b6b46d9bf7aaa7 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 14 Jun 2023 03:49:27 +0000 Subject: [PATCH 18/24] remove dependency --- cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index 2af20945cc..a3633faea4 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -8,7 +8,6 @@ ultra_plonk.bench.cpp # Required libraries for benchmark suites set(LINKED_LIBRARIES - stdlib_primitives stdlib_sha256 stdlib_keccak stdlib_merkle_tree From 2f77f8176abd7a9269f9a507638ff1ec9e81e9f9 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 14 Jun 2023 12:34:58 +0000 Subject: [PATCH 19/24] test commit --- cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt | 2 +- cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index a3633faea4..d9a995e7cf 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -1,4 +1,4 @@ -# Each source represents a separate benchmark suite +# Each source represents a separate benchmark suite set(BENCHMARK_SOURCES standard_honk.bench.cpp standard_plonk.bench.cpp diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index 168be9c221..a556b1121f 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -20,7 +20,6 @@ void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraHonk bench_utils::construct_proof_with_specified_num_iterations(state, test_circuit_function); } -using namespace bench_utils; BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS) From 24bfa546bdf03b13cc2fe19426b922fba0867a32 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 14 Jun 2023 13:22:17 +0000 Subject: [PATCH 20/24] test --- cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index a556b1121f..e834d83ff9 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -20,6 +20,7 @@ void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraHonk bench_utils::construct_proof_with_specified_num_iterations(state, test_circuit_function); } +// Define benchmarks BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit) ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) ->Repetitions(NUM_REPETITIONS) From e0025102d81a45458746d92df83a5ce1836dab9d Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 14 Jun 2023 14:17:33 +0000 Subject: [PATCH 21/24] only on push to master --- .github/workflows/benchmarks.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index bfef80dcaf..25b7be119f 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -5,10 +5,6 @@ on: push: branches: - master - - lde/ultra_bench_update -# on: -# pull_request: -# types: ["labeled", "opened", "synchronize", "reopened"] # This will cancel previous runs when a branch or PR is updated concurrency: From 671850e406b9014206a298db8dd2da0884728a57 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 14 Jun 2023 14:19:23 +0000 Subject: [PATCH 22/24] update comment --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 25b7be119f..9d70efdcb4 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -1,6 +1,6 @@ name: Barretenberg Benchmarks -# For now, run basically whenever anything happens in a PR +# Only run on push to master on: push: branches: From 00d0a57f47b99fb42798d7c9953ebd7ce90f2118 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 15 Jun 2023 00:40:21 +0000 Subject: [PATCH 23/24] updates based on PR feedback --- .../honk_bench/benchmark_utilities.hpp | 57 +++++++++++-------- .../compare_honk_branch_vs_baseline.sh | 24 ++++---- .../compare_honk_to_plonk_standard.sh | 2 +- .../honk_bench/compare_honk_to_plonk_ultra.sh | 2 +- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 8e15858789..2946434176 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -105,29 +105,31 @@ template void generate_ecdsa_verification_test_circuit(Compo std::string message_string = "Instructions unclear, ask again later."; crypto::ecdsa::key_pair account; - account.private_key = curve::fr::random_element(); - account.public_key = curve::g1::one * account.private_key; + for (size_t i = 0; i < num_iterations; i++) { + // Generate unique signature for each iteration + account.private_key = curve::fr::random_element(); + account.public_key = curve::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, account); - bool first_result = - crypto::ecdsa::verify_signature(message_string, account.public_key, signature); + bool first_result = + crypto::ecdsa::verify_signature(message_string, account.public_key, signature); - std::vector rr(signature.r.begin(), signature.r.end()); - std::vector ss(signature.s.begin(), signature.s.end()); - uint8_t vv = signature.v; + std::vector rr(signature.r.begin(), signature.r.end()); + std::vector ss(signature.s.begin(), signature.s.end()); + uint8_t vv = signature.v; - typename curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&composer, account.public_key); + typename curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&composer, account.public_key); - proof_system::plonk::stdlib::ecdsa::signature sig{ typename curve::byte_array_ct(&composer, rr), - typename curve::byte_array_ct(&composer, ss), - proof_system::plonk::stdlib::uint8(&composer, - vv) }; + proof_system::plonk::stdlib::ecdsa::signature sig{ typename curve::byte_array_ct(&composer, rr), + typename curve::byte_array_ct(&composer, ss), + proof_system::plonk::stdlib::uint8( + &composer, vv) }; - typename curve::byte_array_ct message(&composer, message_string); + typename curve::byte_array_ct message(&composer, message_string); - for (size_t i = 0; i < num_iterations; i++) { + // Verify ecdsa signature proof_system::plonk::stdlib::ecdsa::verify_signature void generate_ecdsa_verification_test_circuit(Compo * * @param composer * @param num_iterations - * @todo (luke): should we consider deeper tree? non-zero leaf values? variable index? */ template void generate_merkle_membership_test_circuit(Composer& composer, size_t num_iterations) { @@ -153,15 +154,23 @@ template void generate_merkle_membership_test_circuit(Compos using MerkleTree_ct = merkle_tree::MerkleTree; MemStore store; - auto db = MerkleTree_ct(store, 3); - - // Check that the leaf at index 0 has value 0. - auto zero = field_ct(witness_ct(&composer, fr::zero())).decompose_into_bits(); - field_ct root = witness_ct(&composer, db.root()); + const size_t tree_depth = 7; + auto merkle_tree = MerkleTree_ct(store, tree_depth); for (size_t i = 0; i < num_iterations; i++) { - merkle_tree::check_membership( - root, merkle_tree::create_witness_hash_path(composer, db.get_hash_path(0)), field_ct(0), zero); + // For each iteration update and check the membership of a different value + size_t idx = i; + size_t value = i * 2; + merkle_tree.update_element(idx, value); + + field_ct root_ct = witness_ct(&composer, merkle_tree.root()); + auto idx_ct = field_ct(witness_ct(&composer, fr(idx))).decompose_into_bits(); + auto value_ct = field_ct(value); + + merkle_tree::check_membership(root_ct, + merkle_tree::create_witness_hash_path(composer, merkle_tree.get_hash_path(idx)), + field_ct(value), + idx_ct); } } diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh index 47add30894..71bf3ee5b9 100755 --- a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh @@ -17,12 +17,21 @@ BENCH_TOOLS_DIR="$BUILD_DIR/_deps/benchmark-src/tools" # Install requirements (numpy + scipy) for comparison script if necessary. # Note: By default, installation will occur in $HOME/.local/bin. -pip3 install -r $BUILD_DIR/_deps/benchmark-src/requirements.txt +pip3 install --user -r $BUILD_DIR/_deps/benchmark-src/requirements.txt # Create temporary directory for benchmark results (json) cd $BASE_DIR mkdir $BENCH_RESULTS_DIR +# Build and run bench in current branch +echo -e "\nConfiguring and building $BENCH_TARGET in current feature branch..\n" +rm -rf $BUILD_DIR +cmake --preset bench > /dev/null && cmake --build --preset bench --target $BENCH_TARGET +cd build-bench +BRANCH_RESULTS="$BENCH_RESULTS_DIR/results_branch.json" +echo -e "\nRunning $BENCH_TARGET in feature branch.." +bin/$BENCH_TARGET --benchmark_format=json > $BRANCH_RESULTS + # Checkout baseline branch, run benchmarks, save results in json format echo -e "\nConfiguring and building $BENCH_TARGET in $BASELINE_BRANCH branch..\n" git checkout master > /dev/null @@ -33,19 +42,12 @@ BASELINE_RESULTS="$BENCH_RESULTS_DIR/results_baseline.json" echo -e "\nRunning $BENCH_TARGET in master.." bin/$BENCH_TARGET --benchmark_format=json > $BASELINE_RESULTS -# Checkout working branch (-), run benchmarks, save results in json format -echo -e "\nConfiguring and building $BENCH_TARGET in current feature branch..\n" -git checkout - -rm -rf $BUILD_DIR -cmake --preset bench > /dev/null && cmake --build --preset bench --target $BENCH_TARGET -cd build-bench -BRANCH_RESULTS="$BENCH_RESULTS_DIR/results_branch.json" -echo -e "\nRunning $BENCH_TARGET in feature branch.." -bin/$BENCH_TARGET --benchmark_format=json > $BRANCH_RESULTS - # Call compare.py on the results (json) to get high level statistics. # See docs at https://github.com/google/benchmark/blob/main/docs/tools.md for more details. $BENCH_TOOLS_DIR/compare.py benchmarks $BASELINE_RESULTS $BRANCH_RESULTS +# Return to branch from which the script was called +git checkout - + # Delete the temporary results directory and its contents rm -r $BENCH_RESULTS_DIR diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_standard.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_standard.sh index f30bb4d26c..ad7ecc1f22 100755 --- a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_standard.sh +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_standard.sh @@ -13,7 +13,7 @@ BENCH_TOOLS_DIR="$BUILD_DIR/_deps/benchmark-src/tools" # Install requirements (numpy + scipy) for comparison script if necessary. # Note: By default, installation will occur in $HOME/.local/bin. -pip3 install -r $BUILD_DIR/_deps/benchmark-src/requirements.txt +pip3 install --user -r $BUILD_DIR/_deps/benchmark-src/requirements.txt # Create temporary directory for honk_bench results (json) cd $BASE_DIR diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_ultra.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_ultra.sh index bba5ed9da8..0e5625e930 100755 --- a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_ultra.sh +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_to_plonk_ultra.sh @@ -13,7 +13,7 @@ BENCH_TOOLS_DIR="$BUILD_DIR/_deps/benchmark-src/tools" # Install requirements (numpy + scipy) for comparison script if necessary. # Note: By default, installation will occur in $HOME/.local/bin. -pip3 install -r $BUILD_DIR/_deps/benchmark-src/requirements.txt +pip3 install --user -r $BUILD_DIR/_deps/benchmark-src/requirements.txt # Create temporary directory for honk_bench results (json) cd $BASE_DIR From 5bd1b00e061c229d54b95aba3df3dd8715c19686 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 15 Jun 2023 00:46:06 +0000 Subject: [PATCH 24/24] quick fix --- .../benchmark/honk_bench/benchmark_utilities.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 2946434176..81a12b129e 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -167,10 +167,8 @@ template void generate_merkle_membership_test_circuit(Compos auto idx_ct = field_ct(witness_ct(&composer, fr(idx))).decompose_into_bits(); auto value_ct = field_ct(value); - merkle_tree::check_membership(root_ct, - merkle_tree::create_witness_hash_path(composer, merkle_tree.get_hash_path(idx)), - field_ct(value), - idx_ct); + merkle_tree::check_membership( + root_ct, merkle_tree::create_witness_hash_path(composer, merkle_tree.get_hash_path(idx)), value_ct, idx_ct); } }