Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
7a833ab
too surprising. we should consider removing bootstraps from hash
ludamad Mar 28, 2025
33f2bd2
cache and bench cleanup, add e2e_ivc_bench to cpp/bootstrap.sh
ludamad Mar 29, 2025
1633a79
comment
ludamad Mar 29, 2025
7c864a8
make a lib used just by main.cpp
ludamad Mar 29, 2025
dc29c03
rename to bb cli bench
ludamad Mar 29, 2025
177bd39
e2e bench work
ludamad Mar 29, 2025
ccbd8b1
dont tack on to a duplicated method...
ludamad Mar 31, 2025
1382798
more tweaks
ludamad Mar 31, 2025
c91da61
Merge remote-tracking branch 'origin/master' into ad/e2e-ivc-bench
ludamad Mar 31, 2025
f6b2f9e
libdeflate tweak
ludamad Mar 31, 2025
9aadff0
fixes
ludamad Mar 31, 2025
93d95ba
Merge remote-tracking branch 'origin/master' into ad/ivc-no-make-veri…
ludamad Mar 31, 2025
64cc855
allow calling build_nodejs_module
ludamad Mar 31, 2025
17b160f
Make sure bench script exits early on bad bb cli exit code
ludamad Mar 31, 2025
fee32e2
fix main
ludamad Mar 31, 2025
d197965
benchmark work
ludamad Mar 31, 2025
081d5b4
zone scoped
ludamad Mar 31, 2025
ce52bba
fix execution of main.cpp in wasm
ludamad Apr 1, 2025
7591bf8
Merge remote-tracking branch 'origin/master' into ad/ivc-no-make-veri…
ludamad Apr 1, 2025
cd266c1
port new main.cpp changes
ludamad Apr 2, 2025
11b6f24
add wasm calls to bench
ludamad Apr 2, 2025
36c830c
benchmark both wasm and native
ludamad Apr 2, 2025
80c077e
ivc wasm benches
ludamad Apr 2, 2025
50d5b1a
fix msgpack usage
ludamad Apr 2, 2025
98daf58
make wasm normal again
ludamad Apr 2, 2025
b81fb76
test fix
ludamad Apr 2, 2025
1151d1b
bench fix
ludamad Apr 2, 2025
12ebf59
Merge remote-tracking branch 'origin/master' into ad/ivc-verifier-bre…
ludamad Apr 2, 2025
54f82bb
fix
ludamad Apr 2, 2025
18cd4f4
fix
ludamad Apr 2, 2025
30fa963
fix script in non-interactive use
ludamad Apr 3, 2025
5c5f8d6
debug target. attempt fixes
ludamad Apr 3, 2025
9e55a51
try to fix CI job control.
ludamad Apr 3, 2025
08b2a61
merge master
ludamad Apr 3, 2025
971b911
enable ivc bench
ludamad Apr 3, 2025
d25c3cc
fix wasm code
ludamad Apr 4, 2025
f0f5618
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 4, 2025
d77d224
ffs
ludamad Apr 4, 2025
1ece81a
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 4, 2025
292315e
build dir utility
ludamad Apr 4, 2025
80fc995
set preset
ludamad Apr 4, 2025
406bead
make ci bench flexible
ludamad Apr 4, 2025
b5d5fcf
fixes
ludamad Apr 4, 2025
1dfbecd
Update barretenberg/README.md
ludamad Apr 4, 2025
aa2fa12
Update barretenberg/README.md
ludamad Apr 4, 2025
d4ba5ad
tweaks
ludamad Apr 4, 2025
d3d890a
fix
ludamad Apr 4, 2025
56d2dca
fix
ludamad Apr 4, 2025
a3923a0
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 4, 2025
09c68c1
fix memusage
ludamad Apr 4, 2025
1e30786
oh it works
ludamad Apr 4, 2025
9803f72
fix memusage
ludamad Apr 4, 2025
0c87d96
fix op count summarizes
ludamad Apr 4, 2025
c72bf4d
vk gen
ludamad Apr 7, 2025
79dba97
vk migration
ludamad Apr 7, 2025
105d8a3
progress
ludamad Apr 7, 2025
328bd07
Merge branch 'master' into ad/ivc-no-make-verifier-keys
ludamad Apr 7, 2025
217f9df
Update launch.json
ludamad Apr 8, 2025
f6a5dcf
work towards vk stringing
ludamad Apr 8, 2025
92591bd
civc api changes
ludamad Apr 8, 2025
6d09306
regen bindings...
ludamad Apr 9, 2025
9562630
Update decider_proving_key.hpp
ludamad Apr 9, 2025
d18dc1f
Update ci_benchmark_ivc_flows.sh
ludamad Apr 9, 2025
47005a7
Update commitment_key.hpp
ludamad Apr 9, 2025
7dfbf42
Update try_catch_shim.hpp
ludamad Apr 9, 2025
bb5c13e
fix binding tech debt left in by people manually editing the bindings…
ludamad Apr 9, 2025
b39e65c
ivc vk work
ludamad Apr 9, 2025
410142f
fixes
ludamad Apr 9, 2025
7fa1d0d
remove schnorr from bbjs entirely
ludamad Apr 9, 2025
f37bfd7
just nuke main.ts
ludamad Apr 9, 2025
f395a6b
fix bb option overlapping
ludamad Apr 9, 2025
c1b41d1
fix ivc inputs path option being used twice
ludamad Apr 9, 2025
d54dd07
fix poseidon bindings
ludamad Apr 9, 2025
a7ad083
in the midst of things
ludamad Apr 9, 2025
57f4c60
cull main.ts
ludamad Apr 9, 2025
a718546
reworking private ivc step encoding
ludamad Apr 10, 2025
cbe5e28
missing file
ludamad Apr 10, 2025
c0146b2
rounds of fixes, move to msgpackr throughout
ludamad Apr 10, 2025
1d19a68
rounds of fixes, move to msgpackr throughout
ludamad Apr 10, 2025
8156584
wip
Thunkar Apr 11, 2025
f5c1de3
wip
Thunkar Apr 11, 2025
8cbc9e6
Merge remote-tracking branch 'origin/master' into ad/ivc-no-make-veri…
ludamad Apr 14, 2025
30f3909
cli changes
ludamad Apr 14, 2025
e599155
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 14, 2025
a2fb716
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 14, 2025
faf137f
fixes
ludamad Apr 14, 2025
472c744
yarn.lock fix
ludamad Apr 14, 2025
79d9c2c
civc api pass
ludamad Apr 14, 2025
e7e8204
update flags
ludamad Apr 14, 2025
e0b0def
yarn.lock
ludamad Apr 14, 2025
3d6f674
remake bindings
ludamad Apr 14, 2025
2b8fed1
wip
Apr 14, 2025
4d5e916
Merge remote-tracking branch 'refs/remotes/origin/gj/bb_verification_…
Apr 14, 2025
9facb01
remove civc
ludamad Apr 14, 2025
b5ef9c5
Update CMakeLists.txt
ludamad Apr 14, 2025
e8088cd
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 14, 2025
646c526
noir revert
ludamad Apr 14, 2025
7b6f4b2
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 14, 2025
cabb411
Merge remote-tracking branch 'origin/ad/ivc-no-make-verifier-keys' in…
ludamad Apr 14, 2025
b4852a2
yarn lock
ludamad Apr 14, 2025
eb41175
fix checkpoint
ludamad Apr 14, 2025
55c0e44
serialization gruntwork
ludamad Apr 14, 2025
53c1ccc
ts fixes
ludamad Apr 14, 2025
722006a
allow for capturing inputs
ludamad Apr 14, 2025
33901e4
use heap buffer methods for civc proof in bbjs
ledwards2225 Apr 14, 2025
4cf99ed
quirks
ledwards2225 Apr 14, 2025
fb5662f
undo ser changes
ledwards2225 Apr 14, 2025
059fa3f
Merge branch 'lde/civc_js_msgpack' into gj/bb_verification_repro
ledwards2225 Apr 14, 2025
c2d78cf
Merge branch 'master' into gj/bb_verification_repro
ledwards2225 Apr 14, 2025
564e0a6
make debugging ivc integration tests easier
ludamad Apr 14, 2025
3d45f5f
fix and format
ludamad Apr 15, 2025
589346c
More moving
ludamad Apr 15, 2025
cefc90d
missing file
ludamad Apr 15, 2025
0aa3206
format
ludamad Apr 15, 2025
9ef5b77
format and lint fix
ludamad Apr 15, 2025
e0209c1
adapt test
ludamad Apr 15, 2025
a19569d
fix wasm test
ludamad Apr 15, 2025
f2c6a1f
Update wasm_client_ivc_integration.test.ts
ludamad Apr 15, 2025
d9044fd
fix lint
ludamad Apr 15, 2025
5df58f0
name fix
ludamad Apr 15, 2025
8f7d710
fixes for master
ludamad Apr 15, 2025
c2dc61a
Merge remote-tracking branch 'origin/master' into ad/ivc-verifier-bre…
ludamad Apr 15, 2025
b8561d0
finish merge
ludamad Apr 15, 2025
5713053
Fix msgpack usage
ludamad Apr 15, 2025
e1a7314
update prove_then_verify_client_ivc.sh with caveat
ludamad Apr 15, 2025
c4cae77
introduce a fast bootstrap
ludamad Apr 15, 2025
4722524
Merge remote-tracking branch 'origin/master' into ad/ivc-verifier-bre…
ludamad Apr 15, 2025
12dc1ce
introduce a fast bootstrap
ludamad Apr 15, 2025
98e8874
bootstrap
ludamad Apr 15, 2025
39c4ae5
Remove ---input_type
ludamad Apr 15, 2025
e5f77a3
cleanup
ludamad Apr 15, 2025
09f6c6c
warn if using wrong inputs
ludamad Apr 15, 2025
a2a0bbb
typo
ludamad Apr 15, 2025
259b129
new pinned inputs
ludamad Apr 15, 2025
ab8b3a5
better protection
ludamad Apr 15, 2025
fe6a1d7
merge
ludamad Apr 15, 2025
fa60b49
Merge remote-tracking branch 'origin/gj/bb_verification_repro' into a…
ludamad Apr 15, 2025
565a8d5
stash
ludamad Apr 15, 2025
1db4059
fix encoding
ludamad Apr 15, 2025
94dd7cd
bad ai, stripped goblin of his comments
ludamad Apr 15, 2025
d41542c
Merge remote-tracking branch 'origin/master' into ad/ivc-verifier-bre…
ludamad Apr 16, 2025
873d61b
hackily align accumulates
ludamad Apr 16, 2025
d5613bb
msgpack refactoring
ludamad Apr 16, 2025
57b32e3
impl
ludamad Apr 16, 2025
9477c85
impl
ludamad Apr 16, 2025
4891bef
parsing
ludamad Apr 16, 2025
be4d7d4
fix
ludamad Apr 17, 2025
66f9b2b
fix
ludamad Apr 17, 2025
a573cb7
remake bindings
ludamad Apr 17, 2025
1d05a92
new files
ludamad Apr 17, 2025
8e6ad0d
adapt bindings
ludamad Apr 17, 2025
ad25787
tweaks
ludamad Apr 17, 2025
55b82ab
Test
ludamad Apr 17, 2025
9c2c9b3
fix
ludamad Apr 17, 2025
457ce81
PASSING
ludamad Apr 17, 2025
72acfb6
fixes
ludamad Apr 17, 2025
fc8988a
ok fix fix
ludamad Apr 17, 2025
383f09e
fix bench
ludamad Apr 17, 2025
e7c3d63
test lint fix
ludamad Apr 17, 2025
aa48687
fix bundle size and _accumulate duplication
ludamad Apr 17, 2025
57a240b
default to empty to allow for detection of not passed
ludamad Apr 17, 2025
55bed56
typo
ludamad Apr 17, 2025
81cf33e
typo
ludamad Apr 17, 2025
a8a0ecc
it was deduped, fix comment
ludamad Apr 17, 2025
29cf814
try to move stuff around
ludamad Apr 17, 2025
d91561d
fix bench, I hope
ludamad Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions barretenberg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ To do a single benchmark you can do e.g.
`IVC_BENCH=amm-add-liquidity ./bootstrap.sh bench_ivc origin/master~3`

If one doesn't provide the commit, it generates these IVC inputs on the fly (depends on yarn-project having been bootstrapped).
To use these inputs manually, just abort after input download and run ClientIVC proving with --input runtime_stack on those inputs (stored in `yarn-project/end-to-end/example-app-ivc-inputs-out`).
To use these inputs manually, just abort after input download and run ClientIVC proving on those inputs (stored in `yarn-project/end-to-end/example-app-ivc-inputs-out`).

#### Using Tracy to Profile Memory/CPU/Gate Counts

Expand Down Expand Up @@ -532,7 +532,7 @@ By default, the barretenberg.wasm.gz that is used by bb.js (aka barretenberg/ts)
One can get stack traces working from WASM by running root level ./bootstrap.sh (or otherwise building what you need) and then doing:
```
cmake --build --preset wasm-threads --target barretenberg-debug.wasm.gz
mv build-wasm-threads/barretenberg-debug.wasm.gz build-wasm-threads/barretenberg.wasm.gz
cp build-wasm-threads/bin/barretenberg-debug.wasm.gz ../ts/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz
```

This will mean that any yarn-project or barretenberg/ts tests that run will get stack traces with function names.
Expand All @@ -541,5 +541,5 @@ To get more detailed information use the following (NOTE: takes >10 minutes!):
```
cmake --preset wasm-threads-dbg
cmake --build --preset wasm-threads-dbg --target barretenberg-debug.wasm.gz
mv build-wasm-threads-dbg/barretenberg-debug.wasm.gz build-wasm-threads/barretenberg.wasm.gz
cp build-wasm-threads-dbg/bin/barretenberg-debug.wasm.gz ../ts/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz
```
3 changes: 0 additions & 3 deletions barretenberg/acir_tests/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ function run_benchmark {

# TODO(https://github.com/AztecProtocol/barretenberg/issues/1254): More complete testing, including failure tests
function bench {
# TODO(https://github.com/AztecProtocol/barretenberg/issues/1265) fix acir benchmarking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this issue be closed? I see it doesn't have a description

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. it was the old acir benchmarks. they're probably not coming back at this point

# LOG_FILE=bench-acir.jsonl ./bench_acir_tests.sh

export HARDWARE_CONCURRENCY=16

rm -rf bench-out && mkdir -p bench-out
Expand Down
17 changes: 0 additions & 17 deletions barretenberg/acir_tests/flows/prove_then_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ BFLAG="-b ./target/program.json"
FLAGS="-c $CRS_PATH ${VERBOSE:+-v}"
[ "${RECURSIVE}" = "true" ] && FLAGS+=" --recursive"

# TODO: Use this when client ivc support write_vk. Currently it keeps its own flow.
# case ${SYS:-} in
# "")
# prove_cmd=prove
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will have to anyway rethink this

# verify_cmd=verify
# ;;
# "client_ivc")
# prove_cmd=prove
# verify_cmd=verify
# flags+=" --scheme client_ivc --input_type ${INPUT_TYPE:-single_circuit}"
# ;;
# *)
# prove_cmd=prove_$SYS
# verify_cmd=verify_$SYS
# ;;
# esac

# Test we can perform the proof/verify flow.
# This ensures we test independent pk construction through real/garbage witness data paths.
# We use process substitution pipes to avoid temporary files, which need cleanup, and can collide with parallelism.
Expand Down
15 changes: 3 additions & 12 deletions barretenberg/acir_tests/flows/prove_then_verify_client_ivc.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#!/usr/bin/env bash
# Create intermediate state in a directory. Uses a temp dir to ensure parallel safe and cleans up on exit.
# TODO this is unused
set -eux

INFLAG=${INPUT_TYPE:---input_type runtime_stack}

if [ "$INFLAG" = "--input_type runtime_stack" ]; then
BFLAG=target/acir.msgpack
WFLAG=target/witness.msgpack
else
BFLAG=target/program.json
WFLAG=target/witness.gz
fi

CRS_PATH=${CRS_PATH:-$HOME/.bb-crs}
BIN=$(realpath ${BIN:-../cpp/build/bin/bb})

Expand All @@ -23,6 +14,6 @@ trap "rm -rf $outdir" EXIT
flags="--scheme client_ivc -c $CRS_PATH ${VERBOSE:+-v}"

parallel ::: \
"$BIN prove $flags -b $BFLAG -w $WFLAG $INFLAG --output_format proof -o $outdir" \
"$BIN write_vk $flags -b $BFLAG $INFLAG --verifier_type ivc -o $outdir"
"$BIN prove $flags -i target/ivc-inputs.msgpack $INFLAG --output_format proof -o $outdir" \
"$BIN write_vk $flags -i target/ivc-inputs.msgpack $INFLAG --verifier_type ivc -o $outdir"
$BIN verify $flags -p $outdir/proof -k $outdir/vk
2 changes: 1 addition & 1 deletion barretenberg/acir_tests/flows/sol_honk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eu
VFLAG=${VERBOSE:+-v}
BFLAG="-b ./target/program.json"
FLAGS="-c $CRS_PATH $VFLAG --scheme ultra_honk"
PROVE_FLAGS="$FLAGS $BFLAG --oracle_hash keccak --output_format bytes_and_fields --write_vk --input_type single_circuit"
PROVE_FLAGS="$FLAGS $BFLAG --oracle_hash keccak --output_format bytes_and_fields --write_vk"
VERIFY_FLAGS="$FLAGS --oracle_hash keccak"

outdir=$(mktemp -d)
Expand Down
12 changes: 11 additions & 1 deletion barretenberg/cpp/.clangd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CompileFlags: # Tweak the parse settings
Remove: -fconstexpr-ops-limit=* -Wfatal-errors
Remove:
- "-fconstexpr-ops-limit=*"
- "-Wfatal-errors"
---
# Applies all barretenberg source files
If:
Expand Down Expand Up @@ -51,6 +53,8 @@ Diagnostics:
- readability-container-data-pointer
# Many hits; potential for false positives.
- cppcoreguidelines-pro-type-member-init
# We do use this, so no point banning it. The name is a warning enough.
- cppcoreguidelines-pro-type-reinterpret-cast
# As cryptographers, we often think of bools as 0/1 values; would bloat code in some places.
- modernize-use-bool-literals
# Triggers on every TYPED_TEST
Expand All @@ -71,6 +75,12 @@ Diagnostics:
- modernize-use-auto
# Not worth rewriting. Redundant types are often clearer.
- modernize-return-braced-init-list
# Not worth rewriting. Also some gotchas with mac not accepting emplaces of C++20 default constructors.
- modernize-use-emplace
# We only really use macros where a constexpr would NOT be able to replace its functionality.
- cppcoreguidelines-macro-usage
# Opinionated, we sometimes just want to use a default-derived constructor.
- modernize-use-designated-initializers

--- # this divider is necessary
# Disable some checks for Google Test/Bench
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
},
{
"name": "wasm-threads-assert",
"displayName": "Build for WASM with multithreading and and asserts",
"displayName": "Build for WASM with multithreading and asserts",
"binaryDir": "build-wasm-threads-assert",
"description": "Build with wasi-sdk with asserts",
"inherits": "wasm-threads",
Expand Down
16 changes: 7 additions & 9 deletions barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,9 @@ function bench {
--benchmark_filter="construct_proof_ultrahonk_power_of_2/20$"
}
function ultra_honk_wasm {
wasmtime run --env HARDWARE_CONCURRENCY --env IGNITION_CRS_PATH --env GRUMPKIN_CRS_PATH -Wthreads=y -Sthreads=y --dir=. \
./build-wasm-threads/bin/ultra_honk_bench \
--benchmark_out=./bench-out/ultra_honk_wasm.json \
--benchmark_filter="construct_proof_ultrahonk_power_of_2/20$"
scripts/wasmtime.sh ./build-wasm-threads/bin/ultra_honk_bench \
--benchmark_out=./bench-out/ultra_honk_wasm.json \
--benchmark_filter="construct_proof_ultrahonk_power_of_2/20$"
}

# Client IVC
Expand All @@ -243,10 +242,9 @@ function bench {
--benchmark_filter="ClientIVCBench/Full/6$"
}
function client_ivc_wasm {
wasmtime run --env HARDWARE_CONCURRENCY --env IGNITION_CRS_PATH --env GRUMPKIN_CRS_PATH -Wthreads=y -Sthreads=y --dir=. \
./build-wasm-threads/bin/client_ivc_bench \
--benchmark_out=./bench-out/client_ivc_wasm.json \
--benchmark_filter="ClientIVCBench/Full/6$"
scripts/wasmtime.sh ./build-wasm-threads/bin/client_ivc_bench \
--benchmark_out=./bench-out/client_ivc_wasm.json \
--benchmark_filter="ClientIVCBench/Full/6$"
}

function run_benchmark {
Expand Down Expand Up @@ -300,7 +298,7 @@ case "$cmd" in
# Takes an optional master commit to download them from. Otherwise, downloads from latest master commit.
git fetch origin master

build the benchmarked benches
# build the benchmarked benches
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh.. how was this working

Copy link
Collaborator Author

@ludamad ludamad Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it calls 'build' simply :) its valid BASH

parallel --line-buffered --tag -v denoise ::: \
"build_preset $native_preset --target bb_cli_bench" \
"build_preset wasm-threads --target bb_cli_bench"
Expand Down
138 changes: 63 additions & 75 deletions barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
source $(git rev-parse --show-toplevel)/ci3/source

if [[ $# -ne 2 ]]; then
echo "Usage: $0 <bench_input_folder> <output_folder>"
echo "Usage: $0 <bench_input_folder> <benchmark_output>"
exit 1
fi
export input_folder="$1"
output_folder="$2"

cd ..
export input_folder="$1"
benchmark_output="$2"

echo_header "bb ivc flow bench"

export HARDWARE_CONCURRENCY=16
export IGNITION_CRS_PATH=./srs_db/ignition
export GRUMPKIN_CRS_PATH=./srs_db/grumpkin
export native_preset=${NATIVE_PRESET:-clang16-assert}
export native_build_dir=$(scripts/cmake/preset-build-dir $native_preset)

rm -rf bench-out/ivc && mkdir -p bench-out/ivc
mkdir -p bench-out
rm -rf bench-out/ivc-*

function verify_ivc_flow {
local flow="$1"
Expand All @@ -28,10 +30,10 @@ function verify_ivc_flow {
# TODO(AD): Checking which one would be good, but there isn't too much that can go wrong here.
set +e
echo_stderr "Private verify."
./build/bin/bb verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/private-civc-vk 1>&2
"./$native_build_dir/bin/bb" verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/private-civc-vk 1>&2
local private_result=$?
echo_stderr "Private verify: $private_result."
./build/bin/bb verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/public-civc-vk 1>&2
"./$native_build_dir/bin/bb" verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/public-civc-vk 1>&2
local public_result=$?
echo_stderr "Public verify: $public_result."
if [[ $private_result -eq $public_result ]]; then
Expand All @@ -44,86 +46,71 @@ function verify_ivc_flow {
fi
}

function client_ivc_flow_native {
set -eu
local flow=$1
local flow_folder="$input_folder/$flow"
local start=$(date +%s%N)
mkdir -p "bench-out/$flow-proof-files"
export MEMUSAGE_OUT="bench-out/$flow-proof-files/peak-memory-native-mb.txt"

function bb_cli_bench_native {
export MAIN_ARGS="$*"
memusage ./build/bin/bb_cli_bench \
--benchmark_out=bench-out/$flow-proof-files/op-counts.json \
--benchmark_out_format=json || {
echo "bb_cli_bench failed with args: $*"
function run_bb_cli_bench {
local runtime="$1"
local output="$2"
local args="$3"
export MAIN_ARGS="$args"

if [[ "$runtime" == "native" ]]; then
memusage "./$native_build_dir/bin/bb_cli_bench" \
--benchmark_out=$output/op-counts.json \
--benchmark_out_format=json || {
echo "bb_cli_bench native failed with args: $args"
exit 1
}
}

bb_cli_bench_native prove -o "bench-out/$flow-proof-files" -b "$flow_folder/acir.msgpack" -w "$flow_folder/witnesses.msgpack" --scheme client_ivc --input_type runtime_stack
local end=$(date +%s%N)
local elapsed_ns=$(( end - start ))
local elapsed_ms=$(( elapsed_ns / 1000000 ))
local memory_taken_mb=$(cat "$MEMUSAGE_OUT")
Copy link
Collaborator Author

@ludamad ludamad Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted mostly a refactor, but allows honouring NATIVE_PRESET=op-count-time now with op count times printing. (in the future we may just make op counts part of core bb as they are quite light-weight)

echo "$flow (native) has proven in $((elapsed_ms / 1000))s and peak memory of ${memory_taken_mb}MB."
dump_fail "verify_ivc_flow $flow bench-out/$flow-proof-files/proof"
echo "$flow (native) has verified."
cat > "./bench-out/ivc/$flow-ivc-native.json" <<EOF
{
"benchmarks": [
{
"name": "$flow-ivc-proof",
"time_unit": "ms",
"real_time": ${elapsed_ms}
},
{
"name": "$flow-ivc-proof-memory",
"time_unit": "MB",
"real_time": ${elapsed_ms}
else # wasm
export WASMTIME_ALLOWED_DIRS="--dir=$flow_folder --dir=$output"
# TODO support wasm op count time preset
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb_cli_bench \
--benchmark_out=$output/op-counts.json \
--benchmark_out_format=json || {
echo "bb_cli_bench wasm failed with args: $args"
exit 1
}
]
}
EOF
fi
}

function client_ivc_flow_wasm {
function client_ivc_flow {
set -eu
local flow=$1
local runtime="$1"
local flow="$2"
local flow_folder="$input_folder/$flow"
local start=$(date +%s%N)
mkdir -p "bench-out/$flow-proof-files"
export MEMUSAGE_OUT="bench-out/$flow-proof-files/peak-memory-wasm-mb.txt"

function bb_cli_bench_wasm {
export MAIN_ARGS="$*"
export WASMTIME_ALLOWED_DIRS="--dir=$HOME/.bb-crs --dir="$flow_folder" --dir=bench-out/$flow-proof-files"
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb_cli_bench \
--benchmark_out=bench-out/$flow-proof-files/op-counts.json \
--benchmark_out_format=json || {
echo "bb_cli_bench failed with args: $*"
exit 1
}
}
bb_cli_bench_wasm prove -o "bench-out/$flow-proof-files" -b "$flow_folder/acir.msgpack" -w "$flow_folder/witnesses.msgpack" --scheme client_ivc --input_type runtime_stack
local output="bench-out/ivc-$flow-$runtime"
rm -rf "$output"
mkdir -p "$output"
export MEMUSAGE_OUT="$output/peak-memory-$runtime-mb.txt"

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

if [ -f "$output/op-counts.json" ]; then
scripts/google-bench/summarize-op-counts "$output/op-counts.json"
fi

local end=$(date +%s%N)
local elapsed_ns=$(( end - start ))
local elapsed_ms=$(( elapsed_ns / 1000000 ))
local memory_taken_mb=$(cat "$MEMUSAGE_OUT")
echo "$flow (WASM) has proven in ${elapsed_ms}ms and peak memory of ${memory_taken_mb}MB."
dump_fail "verify_ivc_flow $flow bench-out/$flow-proof-files/proof"
echo "$flow (WASM) has verified."
cat > "./bench-out/ivc/$flow-ivc-wasm.json" <<EOF

echo "$flow ($runtime) has proven in $((elapsed_ms / 1000))s and peak memory of ${memory_taken_mb}MB."
dump_fail "verify_ivc_flow $flow $output/proof"
echo "$flow ($runtime) has verified."

local runtime_suffix=""
[[ "$runtime" == "wasm" ]] && runtime_suffix="-wasm"

cat > "$output/benchmarks.json" <<EOF
{
"benchmarks": [
{
"name": "$flow-ivc-proof-wasm",
"name": "$flow-ivc-proof$runtime_suffix",
"time_unit": "ms",
"real_time": ${elapsed_ms}
},
{
"name": "$flow-ivc-proof-wasm-memory",
"name": "$flow-ivc-proof$runtime_suffix-memory",
"time_unit": "MB",
"real_time": ${memory_taken_mb}
}
Expand All @@ -140,7 +127,7 @@ function run_benchmark {
taskset -c $start_core-$end_core bash -c "$2"
}

export -f verify_ivc_flow client_ivc_flow_native client_ivc_flow_wasm run_benchmark
export -f verify_ivc_flow client_ivc_flow run_bb_cli_bench run_benchmark

# TODO this does not work with smaller core counts - we will soon have a benchmark-wide mechanism for this.
num_cpus=$(get_num_cpus)
Expand All @@ -149,15 +136,16 @@ jobs=$((num_cpus / HARDWARE_CONCURRENCY))
# Split up the flows into chunks to run in parallel - otherwise we run out of CPUs to pin.
if [ -n "${IVC_BENCH:-}" ]; then
# If IVC_BENCH is set, run only that benchmark.
run_benchmark 1 "client_ivc_flow_native $IVC_BENCH"
run_benchmark 1 "client_ivc_flow_wasm $IVC_BENCH"
run_benchmark 1 "client_ivc_flow native $IVC_BENCH"
run_benchmark 1 "client_ivc_flow wasm $IVC_BENCH"
else
parallel -v --line-buffer --tag --jobs "$jobs" run_benchmark {#} '"client_ivc_flow_native {}"' ::: $(ls "$input_folder")
parallel -v --line-buffer --tag --jobs "$jobs" run_benchmark {#} '"client_ivc_flow_wasm {}"' ::: $(ls "$input_folder")
for runtime in native wasm; do
parallel -v --line-buffer --tag --jobs "$jobs" run_benchmark {#} '"client_ivc_flow '$runtime' {}"' ::: $(ls "$input_folder")
done
fi

mkdir -p "$output_folder"
mkdir -p "$benchmark_output"

../scripts/combine_benchmarks.py \
./bench-out/ivc/*.json \
> $output_folder/ivc-bench.json
./bench-out/*/benchmarks.json \
> $benchmark_output/ivc-bench.json
Loading