Skip to content

Commit cd319a0

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/barretenberg
2 parents 92a9074 + 7d0a49b commit cd319a0

19 files changed

Lines changed: 240 additions & 132 deletions

barretenberg/cpp/CMakePresets.json

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,29 @@
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+
},
450473
{
451474
"name": "clang16-coverage",
452475
"displayName": "Build with coverage",
@@ -593,6 +616,16 @@
593616
"inherits": "default",
594617
"configurePreset": "clang16"
595618
},
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+
},
596629
{
597630
"name": "darwin-arm64",
598631
"inherits": "default",
@@ -766,14 +799,14 @@
766799
"configurePreset": "wasm-threads-dbg",
767800
"inheritConfigureEnvironment": true,
768801
"jobs": 0,
769-
"targets": ["barretenberg.wasm", "bb"]
802+
"targets": ["barretenberg.wasm", "bb_cli_bench"]
770803
},
771804
{
772805
"name": "wasm-threads-assert",
773806
"configurePreset": "wasm-threads-assert",
774807
"inheritConfigureEnvironment": true,
775808
"jobs": 0,
776-
"targets": ["barretenberg.wasm", "bb"]
809+
"targets": ["barretenberg.wasm", "bb_cli_bench"]
777810
},
778811
{
779812
"name": "wasm-threads",

barretenberg/cpp/bootstrap.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ 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.
241242
parallel --line-buffered denoise ::: \
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"
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"
244245
cache_upload barretenberg-benchmarks-$hash.zst \
245-
{build,build-wasm-threads}/bin/{ultra_honk_bench,client_ivc_bench,bb}
246+
{build,build-wasm-threads}/bin/{ultra_honk_bench,client_ivc_bench,bb_cli_bench}
246247
fi
247248
}
248249

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

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

299300
# Build both native and wasm benchmark binaries
300301
builds=(
301-
"build_preset $native_preset --target bb"
302+
"build_preset $native_preset --target bb_cli_bench --target bb"
302303
)
303304
if [[ "${NO_WASM:-}" != "1" ]]; then
304-
builds+=("build_preset wasm-threads --target bb")
305+
builds+=("build_preset wasm-threads --target bb_cli_bench")
305306
fi
306307
parallel --line-buffered --tag -v denoise ::: "${builds[@]}"
307308

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 prove`, 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.
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: 10 additions & 12 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"), help="Prefix path for benchmark files.")
9+
parser.add_argument("--prefix", type=Path, default=Path("build-op-count-time"), 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.get("benchmarks", [read_result]):
34-
if BENCHMARK == "" or _bench["name"] == BENCHMARK:
33+
for _bench in read_result["benchmarks"]:
34+
if _bench["name"] == BENCHMARK or BENCHMARK == "":
3535
bench = _bench
3636

3737
bench_components = dict(filter(lambda x: x[0] in to_keep, bench.items()))
@@ -51,14 +51,12 @@
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-
# 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)
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)
6260

6361
print("\nMajor contributors:")
6462
print(
@@ -93,7 +91,7 @@ def print_contributions(prefix, ivc_bench_json, bench_name, components):
9391
try:
9492
with open(prefix / ivc_bench_json, "r") as read_file:
9593
read_result = json.load(read_file)
96-
bench = next((_bench for _bench in read_result.get("benchmarks", [read_result]) if bench_name == "" or _bench["name"] == bench_name), None)
94+
bench = next((_bench for _bench in read_result["benchmarks"] if _bench["name"] == bench_name or bench_name == ""), None)
9795
if not bench:
9896
raise ValueError(f"Benchmark '{bench_name}' not found in the JSON file.")
9997
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")
4+
PREFIX = Path("build-op-count-time")
55
PROTOGALAXY_BENCH_JSON = Path("protogalaxy_bench.json")
6-
BENCHMARK = "fold_k/16"
6+
BENCHMARK = "fold_k<MegaFlavor, 3>/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"
6+
BUILD_DIR="build-op-count-time"
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-
"BB_USE_OP_COUNT_TIME=1 ./$TARGET --benchmark_filter=$FILTER\
14+
"./$TARGET --benchmark_filter=$FILTER\
1515
--benchmark_out=$TARGET.json\
1616
--benchmark_out_format=json"\
17-
clang16-assert\
17+
op-count-time\
1818
"$BUILD_DIR"
1919

2020
# Retrieve output from benching instance

barretenberg/cpp/scripts/benchmark_example_ivc_flow_remote.sh

Lines changed: 6 additions & 5 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"}
4+
TARGET=${1:-"bb_cli_bench"}
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"
10+
BUILD_DIR="build-op-count-time"
1111

1212
# Move above script dir.
1313
cd $(dirname $0)/..
@@ -16,9 +16,10 @@ 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-
"./$TARGET prove -o output --ivc_inputs_path ivc-inputs.msgpack --scheme client_ivc\
20-
--op_counts_out=$TARGET.json"\
21-
clang16-assert\
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\
2223
"$BUILD_DIR"
2324

2425
# 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
6+
BUILD_DIR=build-op-count-time
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-
"BB_USE_OP_COUNT_TIME=1 ./protogalaxy_bench --benchmark_filter=$FILTER\
13+
"./protogalaxy_bench --benchmark_filter=$FILTER\
1414
--benchmark_out=$TARGET.json\
1515
--benchmark_out_format=json"\
16-
clang16-assert\
17-
$BUILD_DIR
16+
op-count-time\
17+
build-op-count-time
1818

1919
# Retrieve output from benching instance
2020
cd $BUILD_DIR

barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh

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

4950
if [[ "$runtime" == "native" ]]; then
50-
memusage "./$native_build_dir/bin/bb" $args \
51-
--op_counts_out=$output/op-counts.json || {
52-
echo "bb native failed with args: $args"
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"
5355
exit 1
5456
}
5557
else # wasm
5658
export WASMTIME_ALLOWED_DIRS="--dir=$flow_folder --dir=$output"
5759
# TODO support wasm op count time preset
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"
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"
6164
exit 1
6265
}
6366
fi
@@ -78,7 +81,7 @@ function client_ivc_flow {
7881

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

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

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 }; // update inputs when check fails
28+
bool update_inputs{ false }; // use file backed memory for polynomials
2929

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

0 commit comments

Comments
 (0)