From e5e25a1aca529f91784af9e8e0dad09d770655b2 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Fri, 26 Jul 2024 21:19:47 +0200 Subject: [PATCH] Configure self-hosted runner for benchmarks job (#6975) --- .github/workflows/osrm-backend.yml | 88 ++++++++++++------------------ 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 59329f539f..fe4ee32482 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -653,7 +653,7 @@ jobs: benchmarks: if: github.event_name == 'pull_request' needs: [format-taginfo-docs] - runs-on: ubuntu-24.04 + runs-on: self-hosted env: CCOMPILER: clang-16 CXXCOMPILER: clang++-16 @@ -664,42 +664,17 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} RUN_BIG_BENCHMARK: ${{ contains(github.event.pull_request.labels.*.name, 'Performance') }} steps: - - name: Enable data.osm.pbf cache - if: ${{ ! env.RUN_BIG_BENCHMARK }} - uses: actions/cache@v4 - with: - path: ~/data.osm.pbf - key: v1-data-osm-pbf - restore-keys: | - v1-data-osm-pbf - - name: Use Node 20 - if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }} - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Enable compiler cache - uses: actions/cache@v4 - with: - path: ~/.ccache - key: v1-ccache-benchmarks-${{ github.sha }} - restore-keys: | - v1-ccache-benchmarks- - - name: Enable Conan cache - uses: actions/cache@v4 - with: - path: ~/.conan - key: v1-conan-benchmarks-${{ github.sha }} - restore-keys: | - v1-conan-benchmarks- - name: Checkout PR Branch uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} path: pr - - name: Install dependencies - run: | - python3 -m pip install "conan<2.0.0" "requests==2.31.0" "numpy==1.26.4" --break-system-packages - sudo apt-get update -y && sudo apt-get install ccache + - name: Activate virtualenv + run: | + python3 -m venv .venv + source .venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV + pip install "conan<2.0.0" "requests==2.31.0" "numpy==1.26.4" - name: Prepare data run: | if [ "$RUN_BIG_BENCHMARK" = "true" ]; then @@ -751,34 +726,43 @@ jobs: make -C test/data # we run benchmarks in tmpfs to avoid impact of disk IO - name: Create folder for tmpfs - run: mkdir -p /opt/benchmarks + run: | + # if by any chance it was mounted before(e.g. due to previous job failed), unmount it + sudo umount ~/benchmarks | true + rm -rf ~/benchmarks + mkdir -p ~/benchmarks + # see https://llvm.org/docs/Benchmarking.html - name: Run PR Benchmarks run: | - sudo mount -t tmpfs -o size=4g none /opt/benchmarks - cp -rf pr/build /opt/benchmarks/build - cp -rf pr/lib /opt/benchmarks/lib - mkdir -p /opt/benchmarks/test - cp -rf pr/test/data /opt/benchmarks/test/data - cp -rf pr/profiles /opt/benchmarks/profiles - - ./pr/scripts/ci/run_benchmarks.sh -f /opt/benchmarks -r $(pwd)/pr_results -s $(pwd)/pr -b /opt/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv - sudo umount /opt/benchmarks + sudo cset shield -c 2-3 -k on + sudo mount -t tmpfs -o size=4g none ~/benchmarks + cp -rf pr/build ~/benchmarks/build + cp -rf pr/lib ~/benchmarks/lib + mkdir -p ~/benchmarks/test + cp -rf pr/test/data ~/benchmarks/test/data + cp -rf pr/profiles ~/benchmarks/profiles + + sudo cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/pr_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv + sudo umount ~/benchmarks + sudo cset shield --reset - name: Run Base Benchmarks run: | - sudo mount -t tmpfs -o size=4g none /opt/benchmarks - cp -rf base/build /opt/benchmarks/build - cp -rf base/lib /opt/benchmarks/lib - mkdir -p /opt/benchmarks/test - cp -rf base/test/data /opt/benchmarks/test/data - cp -rf base/profiles /opt/benchmarks/profiles + sudo cset shield -c 2-3 -k on + sudo mount -t tmpfs -o size=4g none ~/benchmarks + cp -rf base/build ~/benchmarks/build + cp -rf base/lib ~/benchmarks/lib + mkdir -p ~/benchmarks/test + cp -rf base/test/data ~/benchmarks/test/data + cp -rf base/profiles ~/benchmarks/profiles # TODO: remove it when base branch will have this file at needed location - if [ ! -f /opt/benchmarks/test/data/portugal_to_korea.json ]; then - cp base/src/benchmarks/portugal_to_korea.json /opt/benchmarks/test/data/portugal_to_korea.json + if [ ! -f ~/benchmarks/test/data/portugal_to_korea.json ]; then + cp base/src/benchmarks/portugal_to_korea.json ~/benchmarks/test/data/portugal_to_korea.json fi # we intentionally use scripts from PR branch to be able to update them and see results in the same PR - ./pr/scripts/ci/run_benchmarks.sh -f /opt/benchmarks -r $(pwd)/base_results -s $(pwd)/pr -b /opt/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv - sudo umount /opt/benchmarks + sudo cset shield --exec -- cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/base_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv + sudo umount ~/benchmarks + sudo cset shield --reset - name: Post Benchmark Results run: | python3 pr/scripts/ci/post_benchmark_results.py base_results pr_results