Skip to content

Commit 3b82f70

Browse files
AztecBotAztecBotjohnathan79717maramihaliludamad
authored
feat: merge-train/barretenberg (#16337)
See [merge-train-readme.md](https://github.com/AztecProtocol/aztec-packages/blob/next/.github/workflows/merge-train-readme.md). BEGIN_COMMIT_OVERRIDE feat: replace bb_cli_bench and op-count-time build with bb and runtime flag (#16189) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: Jonathan Hao <jonathan@aztec-labs.com> Co-authored-by: maramihali <mara@aztec-labs.com> Co-authored-by: ludamad <domuradical@gmail.com>
1 parent 74199d8 commit 3b82f70

18 files changed

Lines changed: 131 additions & 239 deletions

barretenberg/cpp/CMakePresets.json

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -447,29 +447,6 @@
447447
"CMAKE_EXE_LINKER_FLAGS": "$env{MSAN_LFLAGS}"
448448
}
449449
},
450-
{
451-
"name": "op-count",
452-
"displayName": "Release build with operation counts",
453-
"description": "Build with op counting",
454-
"inherits": "clang16-assert",
455-
"binaryDir": "build-op-count",
456-
"environment": {
457-
"CXXFLAGS": "-DBB_USE_OP_COUNT -DBB_USE_OP_COUNT_TRACK_ONLY"
458-
}
459-
},
460-
{
461-
"name": "op-count-time",
462-
"displayName": "Release build with time and clock counts",
463-
"description": "Build with op counting",
464-
"inherits": "clang16-assert",
465-
"binaryDir": "build-op-count-time",
466-
"cacheVariables": {
467-
"DISABLE_AZTEC_VM": "ON"
468-
},
469-
"environment": {
470-
"CXXFLAGS": "-DBB_USE_OP_COUNT -DBB_USE_OP_COUNT_TIME_ONLY"
471-
}
472-
},
473450
{
474451
"name": "clang16-coverage",
475452
"displayName": "Build with coverage",
@@ -616,16 +593,6 @@
616593
"inherits": "default",
617594
"configurePreset": "clang16"
618595
},
619-
{
620-
"name": "op-count-time",
621-
"inherits": "default",
622-
"configurePreset": "op-count-time"
623-
},
624-
{
625-
"name": "op-count",
626-
"inherits": "default",
627-
"configurePreset": "op-count"
628-
},
629596
{
630597
"name": "darwin-arm64",
631598
"inherits": "default",
@@ -799,14 +766,14 @@
799766
"configurePreset": "wasm-threads-dbg",
800767
"inheritConfigureEnvironment": true,
801768
"jobs": 0,
802-
"targets": ["barretenberg.wasm", "bb_cli_bench"]
769+
"targets": ["barretenberg.wasm", "bb"]
803770
},
804771
{
805772
"name": "wasm-threads-assert",
806773
"configurePreset": "wasm-threads-assert",
807774
"inheritConfigureEnvironment": true,
808775
"jobs": 0,
809-
"targets": ["barretenberg.wasm", "bb_cli_bench"]
776+
"targets": ["barretenberg.wasm", "bb"]
810777
},
811778
{
812779
"name": "wasm-threads",

barretenberg/cpp/bootstrap.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,11 @@ function build_bench {
238238
set -eu
239239
if ! cache_download barretenberg-benchmarks-$hash.zst; then
240240
# Run builds in parallel with different targets per preset
241-
# bb_cli_bench is later used in yarn-project.
242241
parallel --line-buffered denoise ::: \
243-
"build_preset $native_preset --target ultra_honk_bench --target client_ivc_bench --target bb_cli_bench --target honk_solidity_proof_gen" \
244-
"build_preset wasm-threads --target ultra_honk_bench --target client_ivc_bench --target bb_cli_bench"
242+
"build_preset $native_preset --target ultra_honk_bench --target client_ivc_bench --target bb --target honk_solidity_proof_gen" \
243+
"build_preset wasm-threads --target ultra_honk_bench --target client_ivc_bench --target bb"
245244
cache_upload barretenberg-benchmarks-$hash.zst \
246-
{build,build-wasm-threads}/bin/{ultra_honk_bench,client_ivc_bench,bb_cli_bench}
245+
{build,build-wasm-threads}/bin/{ultra_honk_bench,client_ivc_bench,bb}
247246
fi
248247
}
249248

@@ -291,18 +290,18 @@ case "$cmd" in
291290
bench_ivc)
292291
# Intended only for dev usage. For CI usage, we run yarn-project/end-to-end/bootstrap.sh bench.
293292
# Sample usage (CI=1 required for bench results to be visible; exclude NO_WASM=1 to run wasm benchmarks):
294-
# CI=1 NO_WASM=1 NATIVE_PRESET=op-count-time ./barretenberg/cpp/bootstrap.sh bench_ivc transfer_0_recursions+sponsored_fpc
293+
# CI=1 NO_WASM=1 ./barretenberg/cpp/bootstrap.sh bench_ivc transfer_0_recursions+sponsored_fpc
295294
git fetch origin next
296295

297296
flow_filter="${1:-}" # optional string-match filter for flow names
298297
commit_hash="${2:-origin/next~3}" # commit from which to download flow inputs
299298

300299
# Build both native and wasm benchmark binaries
301300
builds=(
302-
"build_preset $native_preset --target bb_cli_bench --target bb"
301+
"build_preset $native_preset --target bb"
303302
)
304303
if [[ "${NO_WASM:-}" != "1" ]]; then
305-
builds+=("build_preset wasm-threads --target bb_cli_bench")
304+
builds+=("build_preset wasm-threads --target bb")
306305
fi
307306
parallel --line-buffered --tag -v denoise ::: "${builds[@]}"
308307

barretenberg/cpp/scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ There are scripts that:
2929

3030
## How
3131
- `./scripts/benchmark_client_ivc.sh` lets you run `client_ivc_bench` remotely and analyze the results.
32-
- `./scripts/benchmark_example_ivc_flow_remote.sh` copies the example flow input you'd like to run to the remote machine, runs `bb_cli_bench`, and analyze the results.
32+
- `./scripts/benchmark_example_ivc_flow_remote.sh` copies the example flow input you'd like to run to the remote machine, runs `bb prove`, and analyze the results.
3333
- For the script to work you need to have the example flows downloaded locally, by `AZTEC_CACHE_COMMIT=origin/next~3 FORCE_CACHE_DOWNLOAD=1 yarn-project/end-to-end/bootstrap.sh build_bench`
3434
- If you have other special needs, look inside the above scripts and see what parameters you can give, or use `./scripts/benchmark_remote.sh`.

barretenberg/cpp/scripts/analyze_client_ivc_bench.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
parser = argparse.ArgumentParser(description="Analyze benchmark JSON data.")
77
parser.add_argument("--json", type=Path, default=Path("client_ivc_bench.json"), help="Benchmark JSON file name.")
88
parser.add_argument("--benchmark", type=str, default="ClientIVCBench/Full/6", help="Benchmark name to analyze.")
9-
parser.add_argument("--prefix", type=Path, default=Path("build-op-count-time"), help="Prefix path for benchmark files.")
9+
parser.add_argument("--prefix", type=Path, default=Path("build"), help="Prefix path for benchmark files.")
1010
args = parser.parse_args()
1111

1212
IVC_BENCH_JSON = args.json
@@ -30,8 +30,8 @@
3030

3131
with open(PREFIX / IVC_BENCH_JSON, "r") as read_file:
3232
read_result = json.load(read_file)
33-
for _bench in read_result["benchmarks"]:
34-
if _bench["name"] == BENCHMARK or BENCHMARK == "":
33+
for _bench in read_result.get("benchmarks", [read_result]):
34+
if BENCHMARK == "" or _bench["name"] == BENCHMARK:
3535
bench = _bench
3636

3737
bench_components = dict(filter(lambda x: x[0] in to_keep, bench.items()))
@@ -51,12 +51,14 @@
5151
time_ms = bench[key] / 1e6
5252
print(f"{key:<{max_label_length}}{time_ms:>8.0f} {time_ms/sum_of_kept_times_ms:>8.2%}")
5353

54-
# Validate that kept times account for most of the total measured time.
55-
total_time_ms = bench["real_time"]
56-
totals = '\nTotal time accounted for: {:.0f}ms/{:.0f}ms = {:.2%}'
57-
totals = totals.format(
58-
sum_of_kept_times_ms, total_time_ms, sum_of_kept_times_ms/total_time_ms)
59-
print(totals)
54+
# There may not be "real_time" if this is from bb cli.
55+
if "real_time" in bench:
56+
# Validate that kept times account for most of the total measured time.
57+
total_time_ms = bench["real_time"]
58+
totals = '\nTotal time accounted for: {:.0f}ms/{:.0f}ms = {:.2%}'
59+
totals = totals.format(
60+
sum_of_kept_times_ms, total_time_ms, sum_of_kept_times_ms/total_time_ms)
61+
print(totals)
6062

6163
print("\nMajor contributors:")
6264
print(
@@ -91,7 +93,7 @@ def print_contributions(prefix, ivc_bench_json, bench_name, components):
9193
try:
9294
with open(prefix / ivc_bench_json, "r") as read_file:
9395
read_result = json.load(read_file)
94-
bench = next((_bench for _bench in read_result["benchmarks"] if _bench["name"] == bench_name or bench_name == ""), None)
96+
bench = next((_bench for _bench in read_result.get("benchmarks", [read_result]) if bench_name == "" or _bench["name"] == bench_name), None)
9597
if not bench:
9698
raise ValueError(f"Benchmark '{bench_name}' not found in the JSON file.")
9799
except FileNotFoundError:

barretenberg/cpp/scripts/analyze_protogalaxy_bench.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import json
22
from pathlib import Path
33

4-
PREFIX = Path("build-op-count-time")
4+
PREFIX = Path("build")
55
PROTOGALAXY_BENCH_JSON = Path("protogalaxy_bench.json")
6-
BENCHMARK = "fold_k<MegaFlavor, 3>/16"
6+
BENCHMARK = "fold_k/16"
77

88
# Single out an independent set of functions accounting for most of BENCHMARK's real_time
99
to_keep = [

barretenberg/cpp/scripts/benchmark_client_ivc.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ set -eu
33

44
TARGET=${1:-"client_ivc_bench"}
55
BENCHMARK="ClientIVCBench/Full/6"
6-
BUILD_DIR="build-op-count-time"
6+
BUILD_DIR="build"
77
FILTER="${BENCHMARK}$" # '$' to ensure only specified bench is run
88

99
# Move above script dir.
1010
cd $(dirname $0)/..
1111

1212
# Measure the benchmarks with ops time counting
1313
./scripts/benchmark_remote.sh "$TARGET"\
14-
"./$TARGET --benchmark_filter=$FILTER\
14+
"BB_USE_OP_COUNT_TIME=1 ./$TARGET --benchmark_filter=$FILTER\
1515
--benchmark_out=$TARGET.json\
1616
--benchmark_out_format=json"\
17-
op-count-time\
17+
clang16-assert\
1818
"$BUILD_DIR"
1919

2020
# Retrieve output from benching instance

barretenberg/cpp/scripts/benchmark_example_ivc_flow_remote.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22
set -eu
33

4-
TARGET=${1:-"bb_cli_bench"}
4+
TARGET=${1:-"bb"}
55
#FLOW=${2:-"ecdsar1+amm_add_liquidity_1_recursions+sponsored_fpc"}
66
#FLOW=${2:-"ecdsar1+transfer_1_recursions+private_fpc"}
77
#FLOW=${2:-"ecdsar1+transfer_1_recursions+sponsored_fpc"}
88
#FLOW=${2:-"ecdsar1+transfer_1_recursions+sponsored_fpc"}
99
FLOW=${2:-"schnorr+deploy_tokenContract_with_registration+sponsored_fpc"}
10-
BUILD_DIR="build-op-count-time"
10+
BUILD_DIR="build"
1111

1212
# Move above script dir.
1313
cd $(dirname $0)/..
@@ -16,10 +16,9 @@ scp $BB_SSH_KEY ../../yarn-project/end-to-end/example-app-ivc-inputs-out/$FLOW/i
1616

1717
# Measure the benchmarks with ops time counting
1818
./scripts/benchmark_remote.sh "$TARGET"\
19-
"MAIN_ARGS='prove -o output --ivc_inputs_path ivc-inputs.msgpack --scheme client_ivc'\
20-
./$TARGET --benchmark_out=$TARGET.json\
21-
--benchmark_out_format=json"\
22-
op-count-time\
19+
"./$TARGET prove -o output --ivc_inputs_path ivc-inputs.msgpack --scheme client_ivc\
20+
--op_counts_out=$TARGET.json"\
21+
clang16-assert\
2322
"$BUILD_DIR"
2423

2524
# Retrieve output from benching instance

barretenberg/cpp/scripts/benchmark_protogalaxy.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ set -eu
33

44
TARGET="protogalaxy_bench"
55
FILTER="/16$"
6-
BUILD_DIR=build-op-count-time
6+
BUILD_DIR=build
77

88
# Move above script dir.
99
cd $(dirname $0)/..
1010

1111
# Measure the benchmarks with ops time counting
1212
./scripts/benchmark_remote.sh protogalaxy_bench\
13-
"./protogalaxy_bench --benchmark_filter=$FILTER\
13+
"BB_USE_OP_COUNT_TIME=1 ./protogalaxy_bench --benchmark_filter=$FILTER\
1414
--benchmark_out=$TARGET.json\
1515
--benchmark_out_format=json"\
16-
op-count-time\
17-
build-op-count-time
16+
clang16-assert\
17+
$BUILD_DIR
1818

1919
# Retrieve output from benching instance
2020
cd $BUILD_DIR

barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,19 @@ function run_bb_cli_bench {
4545
local runtime="$1"
4646
local output="$2"
4747
local args="$3"
48-
export MAIN_ARGS="$args"
4948

5049
if [[ "$runtime" == "native" ]]; then
51-
memusage "./$native_build_dir/bin/bb_cli_bench" \
52-
--benchmark_out=$output/op-counts.json \
53-
--benchmark_out_format=json || {
54-
echo "bb_cli_bench native failed with args: $args"
50+
memusage "./$native_build_dir/bin/bb" $args \
51+
--op_counts_out=$output/op-counts.json || {
52+
echo "bb native failed with args: $args"
5553
exit 1
5654
}
5755
else # wasm
5856
export WASMTIME_ALLOWED_DIRS="--dir=$flow_folder --dir=$output"
5957
# TODO support wasm op count time preset
60-
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb_cli_bench \
61-
--benchmark_out=$output/op-counts.json \
62-
--benchmark_out_format=json || {
63-
echo "bb_cli_bench wasm failed with args: $args"
58+
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb $args \
59+
--op_counts_out=$output/op-counts.json || {
60+
echo "bb wasm failed with args: $args"
6461
exit 1
6562
}
6663
fi
@@ -81,7 +78,7 @@ function client_ivc_flow {
8178

8279
run_bb_cli_bench "$runtime" "$output" "prove -o $output --ivc_inputs_path $flow_folder/ivc-inputs.msgpack --scheme client_ivc -v"
8380

84-
if [[ "${NATIVE_PRESET:-}" == op-count-time && "$runtime" != wasm ]]; then
81+
if [[ "$runtime" != wasm ]]; then
8582
python3 scripts/analyze_client_ivc_bench.py --prefix . --json $output/op-counts.json --benchmark ""
8683
fi
8784

barretenberg/cpp/src/barretenberg/api/api.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class API {
2525
bool write_vk{ false }; // should we addditionally write the verification key when writing the proof
2626
bool include_gates_per_opcode{ false }; // should we include gates_per_opcode in the gates command output
2727
bool slow_low_memory{ false }; // use file backed memory for polynomials
28-
bool update_inputs{ false }; // use file backed memory for polynomials
28+
bool update_inputs{ false }; // update inputs when check fails
2929

3030
friend std::ostream& operator<<(std::ostream& os, const Flags& flags)
3131
{

0 commit comments

Comments
 (0)