From 27edf60651496408a92a37c7b9766881ed54758d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 14 Sep 2023 18:14:26 -0700 Subject: [PATCH] CI: measure perf difference of compiling hello world and post comment on the PR --- .github/workflows/ci.yaml | 12 +++++++++++ ci/aarch64-linux-release.sh | 7 ++++-- ci/measure-perf-delta.sh | 43 +++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 ci/measure-perf-delta.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 27ae6a666cba11c45a8fe73709bda7d7d212b53b..dea9c104092561ebd4690eb7c96e35d47d9d9ba9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,3 +17,15 @@ jobs: uses: actions/checkout@v3 - name: Build and Test run: sh ci/aarch64-linux-release.sh + - name: Post Comment + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const body = fs.readFileSync('perf.txt', 'utf8'); + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body, + }); diff --git a/ci/aarch64-linux-release.sh b/ci/aarch64-linux-release.sh index 369c14dc5f8dcf9f10da60f2a8d48d2c64f7a4fe..dd5bdb43d1e7b0484cfb0d5a87a0ca778c7f6f0b 100644 --- a/ci/aarch64-linux-release.sh +++ b/ci/aarch64-linux-release.sh @@ -81,8 +81,6 @@ rm -rf ../build-new mkdir ../build-new cd ../build-new -export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache" -export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache" export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" @@ -108,3 +106,8 @@ stage3/bin/zig build -p stage4 \ --search-prefix "$PREFIX" \ --zig-lib-dir "$(pwd)/../lib" stage4/bin/zig test ../test/behavior.zig -I../test + +# After all correctness checking, compare performance against the merge-base. +cd .. +sh ci/measure-perf-delta.sh "$ZIG" "$TARGET" "$MCPU" "$PREFIX" || \ + echo "Error occurred measuring the performance delta of this pull request." > perf.txt diff --git a/ci/measure-perf-delta.sh b/ci/measure-perf-delta.sh new file mode 100644 index 0000000000000000000000000000000000000000..064c4d8879ec804ae14f6172d988a538ccbd5f69 --- /dev/null +++ b/ci/measure-perf-delta.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +set -x +set -e + +if [ -z "$GITHUB_BASE_REF" ]; then + exit 0 +fi + +ZIG="$1" +TARGET="$2" +MPCU="$3" +PREFIX="$4" + +git checkout "$GITHUB_BASE_REF" + +rm -rf ../build-base +mkdir ../build-base +cd ../build-base + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +cmake .. \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -DZIG_NO_LIB=ON \ + -GNinja + +unset CC +unset CXX + +ninja install + +cd .. + +poop \ + "build-base/stage3/bin/zig build-exe test/standalone/hello_world/hello.zig" \ + "build-head/stage3/bin/zig build-exe test/standalone/hello_world/hello.zig" \ + > perf.txt -- 2.54.0