Skip to content

Commit 414d38d

Browse files
authored
feat(bb): --print_bench (#16673)
While the pieces were there before, I would say the culmination of them amounts to a new feature. Now if you do --print_bench or BB_BENCH=1 on a bb or a test (or even a bench to get clearer numbers) you will get a listing like below
1 parent 1dadb08 commit 414d38d

File tree

194 files changed

+1239
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+1239
-862
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"name": "Debug CIVC transaction",
3737
"type": "lldb",
3838
"request": "launch",
39-
"program": "${workspaceFolder}/barretenberg/cpp/build-debug-no-avm/bin/bb",
40-
"args": ["prove", "--scheme", "client_ivc", "--output_path", ".", "--ivc_inputs_path", "ivc-inputs.msgpack"],
39+
"program": "${workspaceFolder}/barretenberg/cpp/build-debug-fast-no-avm/bin/bb",
40+
"args": ["prove", "--scheme", "client_ivc", "--output_path", ".", "--ivc_inputs_path", "ivc-inputs.msgpack", "--print_bench"],
4141
"cwd": "${workspaceFolder}/yarn-project/end-to-end/example-app-ivc-inputs-out/ecdsar1+transfer_0_recursions+sponsored_fpc",
4242
"initCommands": [
4343
"command script import ${workspaceFolder}/barretenberg/cpp/scripts/lldb_format.py"

barretenberg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ In terms of general usage, you should be able to use scrolling or the WASD keys
450450

451451
##### Adding Zones
452452

453-
Zones are how you can keep track of where you are relative in the code and how you can bucket allocations together. All of the colored blocks in the Main Thread row and other threads' rows refer to zones. You can nest zones in deeper and deeper scopes, which leads to stacks of these zones. To add a named zone, all you have to do is add PROFILE_THIS() or PROFILE_THIS_NAME(<name>) to a scope and it will create a zone. Note that you can't create multiple zones in the same scope.
453+
Zones are how you can keep track of where you are relative in the code and how you can bucket allocations together. All of the colored blocks in the Main Thread row and other threads' rows refer to zones. You can nest zones in deeper and deeper scopes, which leads to stacks of these zones. To add a named zone, all you have to do is add BB_BENCH_TRACY() or BB_BENCH_TRACY_NAME(<name>) to a scope and it will create a zone. Note that you can't create multiple zones in the same scope.
454454

455455
##### Analyzing Fragmentation
456456

barretenberg/cpp/bootstrap.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,13 @@ case "$cmd" in
308308
export AZTEC_CACHE_COMMIT=$commit_hash
309309
# TODO currently does nothing! to reinstate in cache_download
310310
export FORCE_CACHE_DOWNLOAD=${FORCE_CACHE_DOWNLOAD:-1}
311-
BOOTSTRAP_AFTER=barretenberg BOOSTRAP_TO=yarn-project ../../bootstrap.sh
311+
# make sure that disabling the aztec VM does not interfere with cache results from CI.
312+
DISABLE_AZTEC_VM="" BOOTSTRAP_AFTER=barretenberg BOOSTRAP_TO=yarn-project ../../bootstrap.sh
312313

313314
rm -rf bench-out
314315

315316
# Recreation of logic from bench.
316-
../../yarn-project/end-to-end/bootstrap.sh build_bench
317+
DISABLE_AZTEC_VM="" ../../yarn-project/end-to-end/bootstrap.sh build_bench
317318

318319
# Extract and filter benchmark commands by flow name and wasm/no-wasm
319320
function ivc_bench_cmds {

barretenberg/cpp/cmake/module.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ target_sources(
2626
function(barretenberg_module MODULE_NAME)
2727
file(GLOB_RECURSE SOURCE_FILES *.cpp)
2828
file(GLOB_RECURSE HEADER_FILES *.hpp *.tcc)
29-
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*\.(fuzzer|test|bench).cpp$")
29+
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*\\.(fuzzer|test|bench)\\.cpp$")
3030

3131
target_sources(
3232
barretenberg_headers
@@ -202,8 +202,8 @@ function(barretenberg_module MODULE_NAME)
202202
)
203203
endforeach()
204204
endif()
205-
206205
file(GLOB_RECURSE BENCH_SOURCE_FILES *.bench.cpp)
206+
207207
if(BENCH_SOURCE_FILES AND NOT FUZZING)
208208
foreach(BENCHMARK_SOURCE ${BENCH_SOURCE_FILES})
209209
get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension

barretenberg/cpp/scripts/analyze_client_ivc_bench.py

Lines changed: 0 additions & 129 deletions
This file was deleted.

barretenberg/cpp/scripts/analyze_protogalaxy_bench.py

Lines changed: 0 additions & 61 deletions
This file was deleted.

barretenberg/cpp/scripts/benchmark_client_ivc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 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+
"BB_BENCH=1 ./$TARGET --benchmark_filter=$FILTER\
1515
--benchmark_out=$TARGET.json\
1616
--benchmark_out_format=json"\
1717
clang20\

barretenberg/cpp/scripts/benchmark_example_ivc_flow_remote.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,9 @@ cd $(dirname $0)/..
1515
scp $BB_SSH_KEY ../../yarn-project/end-to-end/example-app-ivc-inputs-out/$FLOW/ivc-inputs.msgpack $BB_SSH_INSTANCE:$BB_SSH_CPP_PATH/build/
1616

1717
# Measure the benchmarks with ops time counting
18+
1819
./scripts/benchmark_remote.sh "$TARGET"\
1920
"./$TARGET prove -o output --ivc_inputs_path ivc-inputs.msgpack --scheme client_ivc\
20-
--op_counts_out=$TARGET.json"\
21+
--print_bench"\
2122
clang20\
2223
"$BUILD_DIR"
23-
24-
# Retrieve output from benching instance
25-
cd $BUILD_DIR
26-
scp $BB_SSH_KEY $BB_SSH_INSTANCE:$BB_SSH_CPP_PATH/build/$TARGET.json .
27-
28-
# Analyze the results
29-
cd ../
30-
python3 ./scripts/analyze_client_ivc_bench.py --json "$TARGET.json" --benchmark "" --prefix "$BUILD_DIR"

barretenberg/cpp/scripts/benchmark_protogalaxy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ 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+
"BB_BENCH=1 ./protogalaxy_bench --benchmark_filter=$FILTER\
1414
--benchmark_out=$TARGET.json\
1515
--benchmark_out_format=json"\
1616
clang20\

barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,18 @@ function verify_ivc_flow {
4444
function run_bb_cli_bench {
4545
local runtime="$1"
4646
local output="$2"
47-
local args="$3"
47+
shift 2
4848

4949
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"
50+
memusage "./$native_build_dir/bin/bb" "$@" || {
51+
echo "bb native failed with args: $@"
5352
exit 1
5453
}
5554
else # wasm
5655
export WASMTIME_ALLOWED_DIRS="--dir=$flow_folder --dir=$output"
5756
# 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"
57+
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb "$@" || {
58+
echo "bb wasm failed with args: $@"
6159
exit 1
6260
}
6361
fi
@@ -76,11 +74,7 @@ function client_ivc_flow {
7674
mkdir -p "$output"
7775
export MEMUSAGE_OUT="$output/peak-memory-mb.txt"
7876

79-
run_bb_cli_bench "$runtime" "$output" "prove -o $output --ivc_inputs_path $flow_folder/ivc-inputs.msgpack --scheme client_ivc -v"
80-
81-
if [[ "$runtime" != wasm ]]; then
82-
python3 scripts/analyze_client_ivc_bench.py --prefix . --json $output/op-counts.json --benchmark ""
83-
fi
77+
run_bb_cli_bench "$runtime" "$output" prove -o $output --ivc_inputs_path $flow_folder/ivc-inputs.msgpack --scheme client_ivc -v --print_bench
8478

8579
local end=$(date +%s%N)
8680
local elapsed_ns=$(( end - start ))

0 commit comments

Comments
 (0)