From e5500bec4fef63e3bcfc0134a4b1763fd752f33c Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 31 Jul 2024 16:00:39 +0000 Subject: [PATCH] chore(avm): vm compilation metrics --- .../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 000000000000..97b0e5d3b39a --- /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"