Skip to content

Add performance engineering skill. #82

Add performance engineering skill.

Add performance engineering skill. #82

Workflow file for this run

name: Bench Linux
on:
# SECURITY INVARIANT: use `pull_request`, NEVER `pull_request_target`.
# `pull_request` runs fork code with a read-only token and no secrets;
# `pull_request_target` would expose a read-write token + secrets to
# untrusted PR code. Benchmarks on PRs are gated by the `benchmarks`
# environment approval below (see the job's `environment:`); pushes to the
# default branches run automatically to keep the CodSpeed baseline fresh.
# `workflow_dispatch` runs are also un-gated (ad-hoc manual runs).
push:
branches: [ main, develop, master ]
pull_request:
branches: [ main, develop, master ]
workflow_dispatch:
permissions:
contents: read
concurrency:
# Per-ref group: a new push to a PR supersedes that PR's older, not-yet-approved
# benchmark run (GitHub can't distinguish "waiting for approval" from "running",
# so cancel-in-progress cancels the stale waiting run too — desired, since the
# superseded commit's run is stale anyway). Per-ref (not global) so one PR never
# cancels another PR's or the default branch's run. The approval gate is now the
# throttle, so global serialization is no longer needed. For default-branch
# pushes, a rapid second push likewise supersedes the first; CodSpeed still
# records the latest commit as the baseline.
group: bench-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CODSPEED_VERSION: v2.3.0
jobs:
build:
# OPT-IN GATE: on pull_request, reference the protected `benchmarks`
# environment so a required reviewer must approve before any PR code runs.
# On push/workflow_dispatch the name is empty -> no environment -> no gate,
# so default-branch baseline runs stay automatic.
environment: ${{ github.event_name == 'pull_request' && 'benchmarks' || '' }}
runs-on: ${{ matrix.os }}
env:
BUILD_CONFIG: "${{ matrix.os }}_${{ matrix.compiler }}_${{ matrix.window }}_${{ matrix.precision_opt == '' && 'double' || matrix.precision_opt == '--enable-float' && 'float' || matrix.precision_opt == '--enable-long-double' && 'long-double' || 'unknown' }}"
name: "${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.window }}-${{ matrix.precision_opt == '' && 'double' || matrix.precision_opt == '--enable-float' && 'float' || matrix.precision_opt == '--enable-long-double' && 'long-double' || 'unknown' }}"
strategy:
matrix:
os: ["codspeed-macro"]
compiler: ["gcc"]
window: ["kaiserbessel"]
precision_opt: ["", "--enable-float", "--enable-long-double"]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
persist-credentials: false
# - name: Disable initramfs update
# run: sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf
# - name: Disable man-db update
# run: sudo rm -f /var/lib/man-db/auto-update
- name: Install dependencies
run: |
sudo apt-get install -y software-properties-common
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install -y libc6-dbg build-essential cmake libfftw3-dev libomp-dev libatomic1
- name: Cache CodSpeed integration library
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: cache-codspeed
with:
path: codspeed-cpp
key: codspeed-cpp-${{ runner.arch }}-${{ matrix.os }}-${{ env.CODSPEED_VERSION }}
- name: Checkout CodSpeed integration library
if: steps.cache-codspeed.outputs.cache-hit != 'true'
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
persist-credentials: false
repository: CodSpeedHQ/codspeed-cpp
ref: "${{ env.CODSPEED_VERSION }}"
path: codspeed-cpp
submodules: recursive
- name: CMake — Configure
shell: bash
env:
WINDOW: ${{ matrix.window }}
PRECISION_OPT: ${{ matrix.precision_opt }}
COMPILER: ${{ matrix.compiler }}
run: |
case "${PRECISION_OPT}" in
"") CMAKE_PREC="" ;;
"--enable-float") CMAKE_PREC="-DNFFT_ENABLE_FLOAT=ON" ;;
"--enable-long-double") CMAKE_PREC="-DNFFT_ENABLE_LONG_DOUBLE=ON" ;;
*) echo "Unknown PRECISION_OPT '${PRECISION_OPT}'" >&2; exit 1 ;;
esac
EXTRA=()
AGNOSTIC_FLAGS="window:1,openmp:1"
[ "${PRECISION_OPT}" = "" ] && AGNOSTIC_FLAGS="$AGNOSTIC_FLAGS,precision:1" || AGNOSTIC_FLAGS="$AGNOSTIC_FLAGS,precision:0"
EXTRA+=( -DNFFT_BENCHMARK_MODE=walltime
-DBENCHMARKS_PREFIX="${BUILD_CONFIG}/"
-DNFFT_AGNOSTIC_BENCHMARKS="$AGNOSTIC_FLAGS"
-DFETCHCONTENT_SOURCE_DIR_CODSPEED="$(pwd)/codspeed-cpp" )
# -falign-functions/-falign-loops: force deterministic code layout so an
# unrelated function's hot loop can't shift to a worse alignment when a
# nearby function changes size (avoids phantom instruction-count regressions).
cmake -S . -B build-cmake \
-DCMAKE_C_FLAGS="-O3 -g -fomit-frame-pointer -fstrict-aliasing -ffast-math -falign-functions=64 -falign-loops=32" \
-DNFFT_WINDOW="${WINDOW}" ${CMAKE_PREC} -DNFFT_ENABLE_OPENMP=ON \
-DNFFT_ENABLE_EXHAUSTIVE_UNIT_TESTS=OFF \
-DNFFT_ENABLE_EXAMPLES=OFF -DNFFT_ENABLE_APPLICATIONS=OFF \
"${EXTRA[@]}"
- name: CMake — Build
run: cmake --build build-cmake -j
- name: CMake — Benchmarks
uses: CodSpeedHQ/action@a4a36bb07c0638b0b4ca52bf1f3dad1b4289e52f # v4
with:
# "walltime" measures real elapsed time instead of the deterministic
# instruction-count "simulation" build. Must match -DCODSPEED_MODE=walltime
# in the configure step above. NOTE: walltime on shared GitHub-hosted
# runners is sensitive to neighbour noise; CodSpeed recommends their
# hosted macro runners for stable walltime data.
mode: walltime
run: |
./build-cmake/benchmarks/bench_nfft_direct
if [ -x ./build-cmake/benchmarks/bench_nfft_direct_omp ]; then
./build-cmake/benchmarks/bench_nfft_direct_omp
fi
./build-cmake/benchmarks/bench_nfct_direct
if [ -x ./build-cmake/benchmarks/bench_nfct_direct_omp ]; then
./build-cmake/benchmarks/bench_nfct_direct_omp
fi
./build-cmake/benchmarks/bench_nfst_direct
if [ -x ./build-cmake/benchmarks/bench_nfst_direct_omp ]; then
./build-cmake/benchmarks/bench_nfst_direct_omp
fi