From de53b6458c6dd8c17187e4d746b7945f5aed2e30 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Fri, 8 Mar 2024 09:57:37 +0100 Subject: [PATCH] Move PGO collection to the separate script --- tools/build/build-many.sh | 8 ++----- tools/build/build-pgo.sh | 21 +++++++++++++++++++ tools/build/{collect-pgo.py => pgo-runner.py} | 0 tools/docs/update-bench-charts.py | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100755 tools/build/build-pgo.sh rename tools/build/{collect-pgo.py => pgo-runner.py} (100%) diff --git a/tools/build/build-many.sh b/tools/build/build-many.sh index 7dd72fd..8468b72 100755 --- a/tools/build/build-many.sh +++ b/tools/build/build-many.sh @@ -62,12 +62,8 @@ do echo "Setup build dependencies" pip install -r ./.requirements/build.txt -r ./.requirements/test.txt # Collect PGO - echo "Building profiling version" - PGO_DATA_DIR="/tmp/pgo-data/$ABI" - RUSTFLAGS="-Cprofile-generate=$PGO_DATA_DIR" python3 -m pip install --editable . - echo "Collecting PGO data" - PYTHONPATH=src/:$PYTHONPATH python3 ./tools/build/collect-pgo.py - $(./tools/build/get-rustup-bin.sh)/llvm-profdata merge -o $PGO_DATA_DIR/merged.profdata $PGO_DATA_DIR + PGO_DATA_DIR=`mktemp -d` + ./tools/build/build-pgo.sh # Build wheel echo "Building wheel" RUSTFLAGS="-Cprofile-use=$PGO_DATA_DIR/merged.profdata" python3 -m build --wheel diff --git a/tools/build/build-pgo.sh b/tools/build/build-pgo.sh new file mode 100755 index 0000000..ac5737b --- /dev/null +++ b/tools/build/build-pgo.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# ------------------------------------------------------------------------ +# Build version which collects PGO data +# ------------------------------------------------------------------------ +# Copyright (C) 2022-24, Gufo Labs +# ------------------------------------------------------------------------ + +PGO_DATA_DIR=$1 +if [ "$PGO_DATA_DIR" = "" ]; then + echo "PGO data dir must be set" + exit 1 +fi + +# Collect PGO +echo "Building profiling version" +RUSTFLAGS="-Cprofile-generate=$PGO_DATA_DIR" python3 -m pip install --editable . +echo "Collecting PGO data" +PYTHONPATH=src/:$PYTHONPATH python3 ./tools/build/pgo-runner.py +echo "Merging profdata" +$(./tools/build/get-rustup-bin.sh)/llvm-profdata merge -o $PGO_DATA_DIR/merged.profdata $PGO_DATA_DIR +echo "PGO profile is written into $PGO_DATA_DIR/merged.profdata" diff --git a/tools/build/collect-pgo.py b/tools/build/pgo-runner.py similarity index 100% rename from tools/build/collect-pgo.py rename to tools/build/pgo-runner.py diff --git a/tools/docs/update-bench-charts.py b/tools/docs/update-bench-charts.py index 310485a..091a28b 100755 --- a/tools/docs/update-bench-charts.py +++ b/tools/docs/update-bench-charts.py @@ -78,7 +78,7 @@ def build_barchart( bench: Benchmark, data: List[Tuple[str, float]], scale: str ) -> None: """ - Build bar chart into SVG file. + Build bar chart into PNG file. Args: bench: Benchmark description.