mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-01-10 04:08:55 -05:00
Refactor run_guest_benches.sh (#3198)
I wanted to refactor the `run_guest_benches.sh` to make it a bit more flexible. With this, it should be possible to test the ECC guest easily (#3118), which actually has 3 guests (manual, out-of-the-box software, hint-optimized software). I also brought the matmul test back. The file structure is not exactly the same as before, but similar (and more organized): https://github.com/powdr-labs/bench-results/tree/gh-pages/results/2025-08-20-1538 (which is from this run: https://github.com/powdr-labs/powdr/actions/runs/17099625118/job/48492387082) --------- Co-authored-by: chriseth <chris@ethereum.org>
This commit is contained in:
@@ -12,51 +12,58 @@ set -e
|
||||
SCRIPT_PATH=$(realpath "${BASH_SOURCE[0]}")
|
||||
SCRIPTS_DIR=$(dirname "$SCRIPT_PATH")
|
||||
|
||||
# function to run using psrecord
|
||||
with_psrecord() {
|
||||
psrecord --include-children --interval 1 --log psrecord.csv --log-format csv --plot psrecord.png "$@"
|
||||
}
|
||||
|
||||
basic_metrics() {
|
||||
python3 $SCRIPTS_DIR/basic_metrics.py --csv *.json > basic_metrics.csv
|
||||
}
|
||||
|
||||
plot_cells() {
|
||||
python3 $SCRIPTS_DIR/plot_trace_cells.py -o trace_cells.png $1 > trace_cells.txt
|
||||
}
|
||||
|
||||
plot_effectiveness() {
|
||||
python3 $SCRIPTS_DIR/../../autoprecompiles/scripts/plot_effectiveness.py $1 --output effectiveness.png
|
||||
}
|
||||
|
||||
# usage: run_bench guest guest_manual_pcp apc_num input
|
||||
run_bench() {
|
||||
guest="$1"
|
||||
guest_manual="$2"
|
||||
input="$2"
|
||||
apcs="$3"
|
||||
input="$4"
|
||||
dir="results/$guest"
|
||||
mkdir -p "$dir"
|
||||
pushd "$dir"
|
||||
# prove with manual precompile if given
|
||||
if [ -n "$guest_manual" ]; then
|
||||
cargo run --bin powdr_openvm -r prove $guest_manual --input "$input" --metrics manual.json --recursion
|
||||
run_name="$4"
|
||||
|
||||
echo ""
|
||||
echo "==== ${run_name} ===="
|
||||
echo ""
|
||||
|
||||
mkdir -p "${run_name}"
|
||||
|
||||
psrecord --include-children --interval 1 \
|
||||
--log "${run_name}"/psrecord.csv \
|
||||
--log-format csv \
|
||||
--plot "${run_name}"/psrecord.png \
|
||||
"cargo run --bin powdr_openvm -r prove \"$guest\" --input \"$input\" --autoprecompiles \"$apcs\" --metrics \"${run_name}/metrics.json\" --recursion --apc-candidates-dir \"${run_name}\""
|
||||
|
||||
python3 "$SCRIPTS_DIR"/plot_trace_cells.py -o "${run_name}"/trace_cells.png "${run_name}"/metrics.json > "${run_name}"/trace_cells.txt
|
||||
|
||||
# apc_candidates.json is only available when apcs > 0
|
||||
if [ "${apcs:-0}" -ne 0 ]; then
|
||||
python3 "$SCRIPTS_DIR"/../../autoprecompiles/scripts/plot_effectiveness.py "${run_name}"/apc_candidates.json --output "${run_name}"/effectiveness.png
|
||||
fi
|
||||
# prove with no APCs to obtain noapc.json for metrics comparison against case with APCs
|
||||
mkdir -p ${apcs}apc
|
||||
cargo run --bin powdr_openvm -r prove $guest --input $input --metrics noapc.json --recursion
|
||||
# prove with APCs and record memory usage; default Pgo::Cell mode also collects data on all APC candidates
|
||||
with_psrecord "cargo run --bin powdr_openvm -r prove $guest --input $input --autoprecompiles $apcs --metrics ${apcs}apc.json --recursion --apc-candidates-dir ${apcs}apc"
|
||||
# process results
|
||||
basic_metrics
|
||||
plot_cells ${apcs}apc.json
|
||||
plot_effectiveness ${apcs}apc/apc_candidates.json
|
||||
|
||||
# Clean up some files that we don't want to to push.
|
||||
rm debug.pil
|
||||
rm ${apcs}apc/*.cbor
|
||||
popd
|
||||
rm -f "${run_name}"/*.cbor
|
||||
}
|
||||
|
||||
# keccak for 10000 iterations, 100 apcs
|
||||
run_bench guest-keccak guest-keccak-manual-precompile 100 10000
|
||||
### Keccak
|
||||
dir="results/keccak"
|
||||
input="10000"
|
||||
|
||||
# run_bench guest-matmul "" 100 0
|
||||
mkdir -p "$dir"
|
||||
pushd "$dir"
|
||||
|
||||
run_bench guest-keccak-manual-precompile "$input" 0 manual
|
||||
run_bench guest-keccak "$input" 0 noapc
|
||||
run_bench guest-keccak "$input" 100 100apc
|
||||
|
||||
python3 $SCRIPTS_DIR/basic_metrics.py --csv **/metrics.json > basic_metrics.csv
|
||||
popd
|
||||
|
||||
### Matmul
|
||||
dir="results/matmul"
|
||||
|
||||
mkdir -p "$dir"
|
||||
pushd "$dir"
|
||||
|
||||
run_bench guest-matmul 0 0 noapc
|
||||
run_bench guest-matmul 0 100 100apc
|
||||
|
||||
python3 "$SCRIPTS_DIR"/basic_metrics.py --csv **/metrics.json > basic_metrics.csv
|
||||
popd
|
||||
|
||||
Reference in New Issue
Block a user