From 448f7d2bdbb9a5feb64dea0be55432ad6a1d84f6 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sun, 8 Sep 2024 06:38:48 +0100 Subject: [PATCH] Hoist benchmarking steps into reusable GH action Signed-off-by: Hanno Becker --- .github/actions/bench/action.yml | 57 ++++++++++++++++++++++++ .github/workflows/bench_ec2_any.yml | 4 ++ .github/workflows/bench_ec2_reusable.yml | 26 +++++------ 3 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 .github/actions/bench/action.yml diff --git a/.github/actions/bench/action.yml b/.github/actions/bench/action.yml new file mode 100644 index 000000000..77d3d1afc --- /dev/null +++ b/.github/actions/bench/action.yml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: Apache-2.0 + +name: Bench MLKEM-C-AArch64 +description: Run benchmarking script + +inputs: + name: + description: Name for the benchmarking run + required: true + perf: + description: Method of obtaining PMU metrics + required: true + default: 'PERF' + type: choice + options: + - NO + - PERF + - PMU + - M1 + cflags: + description: CFLAGS to pass to compilation + required: true + archflags: + description: ARCHFLAGS to pass to compilation + required: true + bench_extra_args: + description: Further arguments to be appended to command line for `bench` script + required: false + default: '' + store_results: + description: Whether to push results to GH pages + required: true + default: 'false' + gh_token: + description: GitHub access token + required: true +runs: + using: composite + steps: + - name: Run benchmark + shell: nix develop .#ci -c bash -e {0} + run: | + tests bench -c ${{ inputs.perf }} --cflags "${{ inputs.cflags }}" --arch-flags "${{ inputs.archflags }}" -v --output output.json ${{ inputs.bench_extra_args }} + - name: Dump benchmark + shell: nix develop .#${{ inputs.devShell }} -c bash -e {0} + if: ${{ inputs.store_results != 'true' }} + run: | + cat output.json + - name: Store benchmark result + if: ${{ inputs.store_results == 'true' }} + uses: benchmark-action/github-action-benchmark@v1 + with: + name: ${{ inputs.name }} + tool: 'customSmallerIsBetter' + output-file-path: output.json + github-token: ${{ inputs.gh_token }} + auto-push: true diff --git a/.github/workflows/bench_ec2_any.yml b/.github/workflows/bench_ec2_any.yml index 20c8ccc52..82fac8a49 100644 --- a/.github/workflows/bench_ec2_any.yml +++ b/.github/workflows/bench_ec2_any.yml @@ -23,6 +23,9 @@ on: always_terminate: description: Indicates if EC2 instance should always be terminated default: true + bench_extra_args: + description: Additional command line to be appended to `tests bench` script + default: '' jobs: bench-ec2-any: name: Ad-hoc benchmark on $${{ github.event.inputs.ec2_instance_type }} @@ -35,4 +38,5 @@ jobs: name: ${{ github.event.inputs.name }} store_results: ${{ github.event.inputs.store_results }} always_terminate: ${{ github.event.inputs.always_terminate }} + bench_extra_args: ${{ github.event.inputs.bench_extra_args }} secrets: inherit diff --git a/.github/workflows/bench_ec2_reusable.yml b/.github/workflows/bench_ec2_reusable.yml index 8bdf596d7..fe2ff89c8 100644 --- a/.github/workflows/bench_ec2_reusable.yml +++ b/.github/workflows/bench_ec2_reusable.yml @@ -30,6 +30,10 @@ on: type: string description: Indicates if instance should always be terminated, even on failure default: 'true' + bench_extra_args: + type: string + description: Additional command line to be appended to `bench` script + default: '' env: AWS_ROLE: arn:aws:iam::559050233797:role/mlkem-c-aarch64-gh-action AWS_REGION: us-east-1 @@ -95,23 +99,15 @@ jobs: $(cat /proc/cpuinfo) EOF - name: Run benchmark - shell: nix develop .#ci -c bash -e {0} - run: | - tests bench -c PERF --cflags "${{ inputs.cflags }}" --arch-flags "${{ inputs.archflags }}" -v --output output.json - - name: Dump benchmark - if: ${{ inputs.store_results != 'true' }} - run: | - cat output.json - - name: Store benchmark result - if: ${{ inputs.store_results == 'true' }} - uses: benchmark-action/github-action-benchmark@v1 + uses: ./.github/actions/bench with: name: ${{ inputs.name }} - tool: 'customSmallerIsBetter' - output-file-path: output.json - github-token: ${{ secrets.AWS_GITHUB_TOKEN }} - auto-push: true - + cflags: ${{ inputs.cflags }} + archflags: ${{ inputs.archflags }} + perf: PERF + store_results: ${{ inputs.store_results }} + bench_extra_args: ${{ inputs.bench_extra_args }} + gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} stop-ec2-runner: name: Stop ${{ github.event.inputs.name }} (${{ github.event.inputs.ec2_instance_type }}) permissions: