Skip to content

Commit c4715b0

Browse files
feat(bb): upload benchmark breakdowns to CI disk storage (#17871)
## Summary Automatically uploads Barretenberg benchmark breakdown JSON files (hierarchical op counts and timings) to CI disk storage when running native builds in CI. These breakdowns are accessible via ci.aztec-labs.com for analysis and performance tracking. ## Changes - **Enable hierarchical benchmarks**: Always run with `--bench_out_hierarchical` flag for native builds to capture detailed performance breakdowns - **Upload to CI infrastructure**: Write benchmark data to both Redis and persistent disk storage - **Accessible via ci.aztec-labs.com**: Breakdowns available at `http://ci.aztec-labs.com/bench-bb-breakdown-<flow>-<sha>` - **Explicit subfolder storage**: New `cache_disk_transfer_to()` function for organized disk storage ## Implementation Uses the existing CI disk logging infrastructure (from #17970): - Writes to Redis for immediate access (30-day retention) - Writes to `/logs-disk/bench/bb-breakdown/` on bastion for long-term storage - Automatic fallback to disk when Redis expires (via rkapp) - Leverages SSH multiplexing for efficient transfers - Explicit subfolder parameter for organized disk layout ## Storage Structure **Redis key format (URL-safe):** ``` bench-bb-breakdown-<flow_name>-<commit_sha> ``` **Disk path (organized in subfolder):** ``` /logs-disk/bench/bb-breakdown/<flow_name>-<commit_sha>.log.gz ``` **Example URL:** ``` http://ci.aztec-labs.com/bench-bb-breakdown-ecdsar1+transfer_0_recursions+sponsored_fpc-a39b92d6e9 ``` ## Benefits - **Simple**: Clean implementation using existing infrastructure - **Reliable**: Same proven mechanism as CI logs - **No race conditions**: Each commit SHA gets unique key - **Fast**: Direct Redis + SSH pipe operations - **Organized**: Explicit subfolder separation from numeric/hex log keys - **URL-safe**: Hyphenated keys work as direct URL paths - **Consistent**: Same pattern as other CI artifacts ## Requirements - Requires `CI_ENABLE_DISK_LOGS=1` to be set in CI - Depends on #17970 for `cache_disk_transfer` infrastructure - Depends on #17940 for `--bench_out_hierarchical` flag 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <[email protected]>
1 parent 657fb63 commit c4715b0

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Performs the chonk private transaction proving benchmarks for our 'realistic apps'.
33
# This is called by yarn-project/end-to-end/bootstrap.sh bench, which creates these inputs from end-to-end tests.
44
source $(git rev-parse --show-toplevel)/ci3/source
5+
source $(git rev-parse --show-toplevel)/ci3/source_redis
6+
source $(git rev-parse --show-toplevel)/ci3/source_cache
57

68
if [[ $# -ne 2 ]]; then
79
echo "Usage: $0 <runtime> <benchmark_folder>"
@@ -45,15 +47,16 @@ function run_bb_cli_bench {
4547
shift 2
4648

4749
if [[ "$runtime" == "native" ]]; then
48-
memusage "./$native_build_dir/bin/bb" "$@" || {
49-
echo "bb native failed with args: $@"
50+
# Add --bench_out_hierarchical flag for native builds to capture hierarchical op counts and timings
51+
memusage "./$native_build_dir/bin/bb" "$@" "--bench_out_hierarchical" "$output/benchmark_breakdown.json" || {
52+
echo "bb native failed with args: $@ --bench_out_hierarchical $output/benchmark_breakdown.json"
5053
exit 1
5154
}
5255
else # wasm
5356
export WASMTIME_ALLOWED_DIRS="--dir=$flow_folder --dir=$output"
54-
# TODO support wasm op count time preset
55-
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb "$@" || {
56-
echo "bb wasm failed with args: $@"
57+
# Add --bench_out_hierarchical flag for wasm builds to capture hierarchical op counts and timings
58+
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb "$@" "--bench_out_hierarchical" "$output/benchmark_breakdown.json" || {
59+
echo "bb wasm failed with args: $@ --bench_out_hierarchical $output/benchmark_breakdown.json"
5760
exit 1
5861
}
5962
fi
@@ -102,3 +105,37 @@ EOF
102105
export -f verify_ivc_flow run_bb_cli_bench
103106

104107
chonk_flow $1 $2
108+
109+
# Upload benchmark breakdown (op counts and timings) to disk if running in CI
110+
if [[ "${CI:-}" == "1" ]] && [[ "${CI_ENABLE_DISK_LOGS:-0}" == "1" ]]; then
111+
echo_header "Uploading Barretenberg benchmark breakdowns"
112+
113+
runtime="$1"
114+
flow_name="$(basename $2)"
115+
benchmark_breakdown_file="bench-out/app-proving/$flow_name/$runtime/benchmark_breakdown.json"
116+
117+
if [[ -f "$benchmark_breakdown_file" ]]; then
118+
current_sha=$(git rev-parse HEAD)
119+
120+
# Create cache key: bench-bb-breakdown-<runtime>-<flow_name>-<sha>
121+
# This will be accessible at: http://ci.aztec-labs.com/bench-bb-breakdown-<runtime>-<flow_name>-<sha>
122+
cache_key="bench-bb-breakdown-${runtime}-${flow_name}-${current_sha}"
123+
124+
# Upload to Redis (30 day retention) and disk (bench/bb-breakdown subfolder)
125+
{
126+
# Write to Redis for ci.aztec-labs.com access
127+
cat "$benchmark_breakdown_file" | gzip | redis_cli -x SETEX "$cache_key" 2592000 &>/dev/null
128+
129+
# Write to disk in explicit subfolder (only if disk logging enabled)
130+
if [[ "${CI_ENABLE_DISK_LOGS:-0}" == "1" ]]; then
131+
# Strip the prefix from key when writing to disk subfolder
132+
disk_key="${cache_key#bench-bb-breakdown-}"
133+
cat "$benchmark_breakdown_file" | gzip | cache_disk_transfer_to "bench/bb-breakdown" "$disk_key"
134+
fi
135+
} &
136+
137+
echo "Uploaded benchmark breakdown: http://ci.aztec-labs.com/$cache_key"
138+
else
139+
echo "Warning: benchmark breakdown file not found at $benchmark_breakdown_file"
140+
fi
141+
fi

ci3/source_cache

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ function cache_disk_transfer {
1616
"mkdir -p /logs-disk/${prefix} && cat > /logs-disk/${prefix}/${key}.log.gz" &>/dev/null
1717
}
1818

19+
# Transfer to bastion with explicit subfolder (accepts gzipped data on stdin)
20+
# Usage: cat file.gz | cache_disk_transfer_to <subfolder> <key>
21+
function cache_disk_transfer_to {
22+
local subfolder="$1"
23+
local key="$2"
24+
25+
# Transfer via SSH pipe using persistent multiplexed connection
26+
ssh -F "${ci3}/aws/build_instance_ssh_config" \
27+
-o ConnectTimeout=5 \
28+
ci-bastion.aztecprotocol.com \
29+
"mkdir -p /logs-disk/${subfolder} && cat > /logs-disk/${subfolder}/${key}.log.gz" &>/dev/null
30+
}
31+
1932
# Persistent cache function that writes to both Redis and disk
2033
function cache_persistent {
2134
local key="$1"
@@ -40,4 +53,4 @@ function cache_persistent {
4053
}
4154

4255
# Export functions
43-
export -f cache_disk_transfer cache_persistent
56+
export -f cache_disk_transfer cache_disk_transfer_to cache_persistent

0 commit comments

Comments
 (0)