Skip to content

Commit

Permalink
Merge branch 'master' into spy/sandbox-for-all-e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy authored Oct 20, 2023
2 parents ca5b32d + a467b96 commit 2907005
Show file tree
Hide file tree
Showing 75 changed files with 1,235 additions and 776 deletions.
56 changes: 0 additions & 56 deletions barretenberg/.github/workflows/nix.yml

This file was deleted.

4 changes: 2 additions & 2 deletions barretenberg/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/AztecProtocol/barretenberg
branch = master
commit = 491aa9d0f86d0b19b05d0805bfe3dbcccb249472
parent = a60c70dca1d920ad88511f77be3ad186afab7bdb
commit = 8b5ad73c5eff8daf734bda54acfbc28f97e73c0f
parent = 73106008f464328935997028ca18698965b579a5
method = merge
cmdver = 0.4.6
49 changes: 30 additions & 19 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,34 +183,40 @@
"MULTITHREADING": "ON"
}
},
{
"name": "xray-1thread",
"displayName": "Build with single-threaded XRay Profiling",
"description": "Build with Clang and enable single-threaded LLVM XRay for profiling",
"generator": "Unix Makefiles",
"inherits": "clang16",
"environment": {
"CFLAGS": "-fxray-instrument -fxray-instruction-threshold=10",
"CXXFLAGS": "-fxray-instrument -fxray-instruction-threshold=10",
"LDFLAGS": "-fxray-instrument -fxray-instruction-threshold=10"
},
"cacheVariables": {
"MULTITHREADING": "OFF"
},
"binaryDir": "build-xray-1thread"
},
{
"name": "xray",
"displayName": "Build with multi-threaded XRay Profiling",
"description": "Build with Clang and enable multi-threaded LLVM XRay for profiling",
"generator": "Unix Makefiles",
"inherits": "clang16",
"environment": {
"CFLAGS": "-fxray-instrument -fxray-instruction-threshold=10",
"CXXFLAGS": "-fxray-instrument -fxray-instruction-threshold=10",
"LDFLAGS": "-fxray-instrument -fxray-instruction-threshold=10"
"CFLAGS": "-fxray-instrument -fxray-instruction-threshold=100",
"CXXFLAGS": "-fxray-instrument -fxray-instruction-threshold=100",
"LDFLAGS": "-fxray-instrument -fxray-instruction-threshold=100"
},
"binaryDir": "build-xray"
},
{
"name": "xray-verbose",
"displayName": "Build with detailed XRay Profiling",
"description": "Build with Clang and enable detailed LLVM XRay for profiling",
"inherits": "xray",
"environment": {
"CFLAGS": "-fxray-instrument -fxray-instruction-threshold=100 -finline-max-stacksize=150",
"CXXFLAGS": "-fxray-instrument -fxray-instruction-threshold=100 -finline-max-stacksize=150",
"LDFLAGS": "-fxray-instrument -fxray-instruction-threshold=100 -finline-max-stacksize=150"
},
"binaryDir": "build-xray-verbose"
},
{
"name": "xray-1thread",
"displayName": "Build with single-threaded XRay Profiling",
"description": "Build with Clang and enable single-threaded LLVM XRay for profiling",
"inherits": "xray",
"cacheVariables": {
"MULTITHREADING": "OFF"
},
"binaryDir": "build-xray-1thread"
}
],
"buildPresets": [
Expand Down Expand Up @@ -303,6 +309,11 @@
"jobs": 0,
"targets": ["barretenberg.wasm"]
},
{
"name": "xray-verbose",
"configurePreset": "xray-verbose",
"inherits": "default"
},
{
"name": "xray-1thread",
"configurePreset": "xray-1thread",
Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/scripts/collect_profile_information.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ llvm-xray-16 stack xray-log.honk_bench_main_simple.* \
--instr_map=./bin/honk_bench_main_simple --stack-format=flame --aggregate-threads --aggregation-type=time --all-stacks \
| node ../scripts/llvm_xray_stack_flame_corrector.js \
| shorten_cpp_names \
| ../scripts/flamegraph.pl > xray.svg
| ../scripts/flamegraph.pl --width 1200 --fontsize 10 \
> xray.svg
echo "Profiling complete, now you can do e.g. 'scp mainframe:`readlink -f xray.svg` .' on a local terminal and open the SVG in a browser."
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ add_subdirectory(decrypt_bench)
add_subdirectory(pippenger_bench)
add_subdirectory(plonk_bench)
add_subdirectory(honk_bench)
add_subdirectory(relations_bench)
add_subdirectory(relations_bench)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BASELINE_BRANCH="master"

echo -e "\nComparing $BENCH_TARGET between $BASELINE_BRANCH and current branch:"
# Set some directories
BASE_DIR="$HOME/barretenberg/cpp"
BASE_DIR="$HOME/aztec-packages/barretenberg/cpp"
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Each source represents a separate benchmark suite
set(BENCHMARK_SOURCES
standard_plonk.bench.cpp
ultra_honk.bench.cpp
ultra_plonk.bench.cpp
standard_plonk.bench.cpp
ultra_honk.bench.cpp
ultra_plonk.bench.cpp
)

# Required libraries for benchmark suites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ template <typename Builder> void generate_basic_arithmetic_circuit(Builder& buil
proof_system::plonk::stdlib::field_t b(
proof_system::plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element()));
proof_system::plonk::stdlib::field_t c(&builder);
if (num_gates < 4) {
throw std::runtime_error("too few gates");
}
for (size_t i = 0; i < (num_gates / 4) - 4; ++i) {
c = a + b;
c = a * c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

echo -e '\nComparing Ultra Plonk/Honk benchmarks.'
# Set some directories
BASE_DIR="$HOME/barretenberg/cpp"
BASE_DIR="$HOME/aztec-packages/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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@
#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp"
#include "barretenberg/stdlib/primitives/witness/witness.hpp"

using namespace proof_system::plonk;

using UltraBuilder = proof_system::UltraCircuitBuilder;
using UltraHonk = proof_system::honk::UltraComposer;
using namespace proof_system;

template <typename Builder> void generate_sha256_test_circuit(Builder& builder, size_t num_iterations)
{
std::string in;
in.resize(32);
proof_system::plonk::stdlib::packed_byte_array<Builder> input(&builder, in);
plonk::stdlib::packed_byte_array<Builder> input(&builder, in);
for (size_t i = 0; i < num_iterations; i++) {
input = proof_system::plonk::stdlib::sha256<Builder>(input);
input = plonk::stdlib::sha256<Builder>(input);
}
}

BBERG_INSTRUMENT BBERG_NOINLINE void sumcheck_profiling(honk::UltraProver& ext_prover)
{
ext_prover.construct_proof();
for (size_t i = 0; i < 200; i++) {
// Bench sumcheck
ext_prover.execute_relation_check_rounds();
}
}

Expand All @@ -44,15 +50,14 @@ void construct_proof_ultra() noexcept
{
barretenberg::srs::init_crs_factory("../srs_db/ignition");
// Constuct circuit and prover; don't include this part in measurement
auto builder = typename UltraHonk::CircuitBuilder();
generate_sha256_test_circuit<UltraBuilder>(builder, 1);
honk::UltraComposer::CircuitBuilder builder;
generate_sha256_test_circuit(builder, 1);
std::cout << "gates: " << builder.get_total_circuit_size() << std::endl;

auto composer = UltraHonk();
auto instance = composer.create_instance(builder);
auto ext_prover = composer.create_prover(instance);
for (size_t i = 0; i < 10; i++) {
auto proof = ext_prover.construct_proof();
}
honk::UltraComposer composer;
std::shared_ptr<honk::UltraComposer::Instance> instance = composer.create_instance(builder);
honk::UltraProver ext_prover = composer.create_prover(instance);
sumcheck_profiling(ext_prover);
}

int main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraBuil
BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);
BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &bench_utils::generate_keccak_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);
BENCHMARK_CAPTURE(construct_proof_ultra,
ecdsa_verification,
&bench_utils::generate_ecdsa_verification_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);
BENCHMARK_CAPTURE(construct_proof_ultra,
merkle_membership,
&bench_utils::generate_merkle_membership_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);

} // namespace ultra_honk_bench
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ void construct_proof_ultra(State& state, void (*test_circuit_function)(UltraBuil
BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &bench_utils::generate_sha256_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);
BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &bench_utils::generate_keccak_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);
BENCHMARK_CAPTURE(construct_proof_ultra,
ecdsa_verification,
&bench_utils::generate_ecdsa_verification_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);
BENCHMARK_CAPTURE(construct_proof_ultra,
merkle_membership,
&bench_utils::generate_merkle_membership_test_circuit<UltraBuilder>)
->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS)
->Repetitions(NUM_REPETITIONS)
->Unit(::benchmark::kSecond);
->Unit(::benchmark::kMillisecond);

} // namespace ultra_plonk_bench
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Each source represents a separate benchmark suite
set(BENCHMARK_SOURCES
barycentric.bench.cpp
relations.bench.cpp
barycentric.bench.cpp
relations.bench.cpp
widget.bench.cpp
)

# Required libraries for benchmark suites
set(LINKED_LIBRARIES
polynomials
proof_system
benchmark::benchmark
transcript
stdlib_primitives
)

# Add executable and custom target for each suite, e.g. ultra_honk_bench
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp"
#include "barretenberg/honk/flavor/goblin_ultra.hpp"
#include "barretenberg/honk/flavor/ultra.hpp"
#include "barretenberg/plonk/composer/standard_composer.hpp"
#include "barretenberg/plonk/composer/ultra_composer.hpp"
#include "barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp"
#include <benchmark/benchmark.h>

namespace {
auto& engine = numeric::random::get_debug_engine();
}

namespace proof_system::plonk {

template <typename Flavor, typename Widget> void execute_widget(::benchmark::State& state)
{
barretenberg::srs::init_crs_factory("../srs_db/ignition");
auto inner_composer = plonk::UltraComposer();
auto builder = typename plonk::UltraComposer::CircuitBuilder();
bench_utils::generate_basic_arithmetic_circuit(builder, 80);
auto inner_prover = inner_composer.create_prover(builder);
auto inner_proof = inner_prover.construct_proof();
for (auto _ : state) {
Widget widget(inner_composer.circuit_proving_key.get());
widget.compute_quotient_contribution(barretenberg::fr::random_element(), inner_prover.transcript);
}
}

void plookup_auxiliary_widget(::benchmark::State& state) noexcept
{
execute_widget<honk::flavor::Ultra, ProverPlookupAuxiliaryWidget<ultra_settings>>(state);
}
BENCHMARK(plookup_auxiliary_widget);

} // namespace proof_system::plonk
18 changes: 18 additions & 0 deletions barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#ifdef _WIN32
#define BBERG_INLINE __forceinline inline
#else
#define BBERG_INLINE __attribute__((always_inline)) inline
#endif

// TODO(AD): Other compilers
#if defined(__clang__)
#define BBERG_INSTRUMENT [[clang::xray_always_instrument]]
#define BBERG_NO_INSTRUMENT [[clang::xray_never_instrument]]
#define BBERG_NOINLINE [[clang::noinline]]
#else
#define BBERG_INSTRUMENT
#define BBERG_NO_INSTRUMENT
#define BBERG_NOINLINE
#endif
7 changes: 0 additions & 7 deletions barretenberg/cpp/src/barretenberg/common/inline.hpp

This file was deleted.

Loading

0 comments on commit 2907005

Please sign in to comment.