From 0d83cde126789016cc15087b7ff0cfb26eb31818 Mon Sep 17 00:00:00 2001 From: Ilyas Ridhuan Date: Thu, 1 Aug 2024 16:57:33 +0100 Subject: [PATCH] chore(avm): vm compilation metrics (#7704) ``` % /path/to/aztec-packages/barretenberg/cpp/scripts/analyze_vm_compile_time.sh clang16 bb VM Total Compilation time(ms): 539039 % cat build-clang16-compiler-profile/avm_compilation_summary.json [ { "name": "avm_trace/avm_alu_trace.cpp.json", "time(ms)": 11563 }, { "name": "avm_trace/avm_binary_trace.cpp.json", "time(ms)": 9615 }, { "name": "avm_trace/avm_deserialization.cpp.json", "time(ms)": 9933 }, { "name": "avm_trace/avm_execution.cpp.json", "time(ms)": 60117 }, { "name": "avm_trace/avm_gas_trace.cpp.json", "time(ms)": 8830 }, { "name": "avm_trace/avm_helper.cpp.json", "time(ms)": 9032 }, { "name": "avm_trace/avm_kernel_trace.cpp.json", "time(ms)": 8271 }, { "name": "avm_trace/avm_mem_trace.cpp.json", "time(ms)": 9633 }, { "name": "avm_trace/avm_opcode.cpp.json", "time(ms)": 2278 }, { "name": "avm_trace/avm_trace.cpp.json", "time(ms)": 17569 }, { "name": "avm_trace/fixed_gas.cpp.json", "time(ms)": 8957 }, { "name": "avm_trace/fixed_powers.cpp.json", "time(ms)": 8296 }, { "name": "avm_trace/gadgets/avm_conversion_trace.cpp.json", "time(ms)": 8487 }, { "name": "avm_trace/gadgets/avm_ecc.cpp.json", "time(ms)": 9261 }, { "name": "avm_trace/gadgets/avm_keccak.cpp.json", "time(ms)": 7960 { "name": "avm_trace/gadgets/avm_pedersen.cpp.json", "time(ms)": 8289 }, { "name": "avm_trace/gadgets/avm_poseidon2.cpp.json", "time(ms)": 8536 }, { "name": "avm_trace/gadgets/avm_sha256.cpp.json", "time(ms)": 8177 }, { "name": "avm_trace/gadgets/avm_slice_trace.cpp.json", "time(ms)": 8233 }, { "name": "generated/avm_circuit_builder.cpp.json", "time(ms)": 55427 }, { "name": "generated/avm_composer.cpp.json", "time(ms)": 52066 }, { "name": "generated/avm_flavor.cpp.json", "time(ms)": 45989 }, { "name": "generated/avm_full_row.cpp.json", "time(ms)": 12241 }, { "name": "generated/avm_prover.cpp.json", "time(ms)": 88277 }, { "name": "generated/avm_verifier.cpp.json", "time(ms)": 57994 }, { "name": "stats.cpp.json", "time(ms)": 4008 } ] ``` --- .../cpp/scripts/analyze_vm_compile_time.sh | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 barretenberg/cpp/scripts/analyze_vm_compile_time.sh diff --git a/barretenberg/cpp/scripts/analyze_vm_compile_time.sh b/barretenberg/cpp/scripts/analyze_vm_compile_time.sh new file mode 100755 index 00000000000..97b0e5d3b39 --- /dev/null +++ b/barretenberg/cpp/scripts/analyze_vm_compile_time.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# This script summarises the compilation time for the vm +# The summary json file is outputted to $BUILD_DIR/avm_compilation_summary.json +# it takes in two params the preset(e.g. clang16, clang16-dbg) and a target (e.g. bb, vm) +# it can be called like this => ./analyze_vm_compile_time.sh clang16 bb +set -eu +# So we can glob recursively +shopt -s globstar + +PRESET="${1:-wasm-threads}" +TARGET="${2:-barretenberg.wasm}" + +BUILD_DIR=build-$PRESET-compiler-profile + +cd $(dirname $0)/.. + +# Run the analyse script if we dont already have the specific directory +if [ ! -d $BUILD_DIR ]; then + echo -e "\n$BUILD_DIR not found, running $(dirname $0)/analyze_compile_time.sh $PRESET $TARGET" + ./scripts/analyze_compile_time.sh $PRESET $TARGET +else + echo -e "\n$BUILD_DIR found, using existing results" +fi + +# Run summary analysis +cd build-$PRESET-compiler-profile +pushd src/barretenberg/vm/CMakeFiles/vm_objects.dir/ > /dev/null 2>&1 +# Process vm json profiling files and "simplify" them in a summary +jq -cn 'inputs | .traceEvents | map(select(.name == "Total ExecuteCompiler")) | map({ name: input_filename, "time(ms)": .args."avg ms"})' **/**.cpp.json | jq -s add > avm_compilation_summary.json +# Compute total time +TOTAL_TIME=$(jq 'map(."time(ms)") | add' avm_compilation_summary.json) +echo -e "\nVM Total Compilation time(ms): $TOTAL_TIME" +popd > /dev/null 2>&1 +mv ./src/barretenberg/vm/CMakeFiles/vm_objects.dir/avm_compilation_summary.json . +echo -e "Summary file outputted to $BUILD_DIR/avm_compilation_summary.json"