-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Miniprotocol Codec Benchmarks | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
merge_group: | ||
|
||
jobs: | ||
run-benchmarks: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ghc: ["8.10.7", "9.6.3"] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
env: | ||
# Modify this value to "invalidate" all cabal caches. | ||
CABAL_CACHE_VERSION: "2022-12-30" | ||
# Modify this value to "invalidate" the cabal store cache only. | ||
CACHE_VERSION: "20220919" | ||
# Modify this value to "invalidate" the dist-newstyle cache only. | ||
DIST_CACHE_VERSION: "20221122" | ||
|
||
steps: | ||
|
||
- name: Install Haskell | ||
uses: input-output-hk/setup-haskell@v1 | ||
id: setup-haskell | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
cabal-version: "3.10.1.0" | ||
pacman-packages: > | ||
mingw-w64-x86_64-pkg-config | ||
mingw-w64-x86_64-openssl | ||
mingw-w64-x86_64-sed | ||
base-devel | ||
autoconf-wrapper | ||
autoconf | ||
automake | ||
libtool | ||
make | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Configure cabal.project.local" | ||
run: | | ||
cp scripts/ci/cabal.project.local.${{ runner.os }} cabal.project.local | ||
- name: Update PATH | ||
if: runner.os == 'Windows' | ||
run: | | ||
$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH) | ||
echo "PATH=$env:PATH" >> $env:GITHUB_ENV | ||
- name: Update Hackage and CHaP | ||
run: cabal update | ||
|
||
- name: Record dependencies | ||
id: record-deps | ||
run: | | ||
cabal build all --dry-run | ||
cat dist-newstyle/cache/plan.json | jq -L .github/workflows/jq-install-plan | sort | uniq > dependencies.txt | ||
- uses: actions/cache/restore@v3 | ||
name: "Restore cache: `cabal store`" | ||
with: | ||
path: ${{ steps.setup-haskell.outputs.cabal-store }} | ||
key: cache-dependencies-${{ env.CABAL_CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} | ||
restore-keys: cache-dependencies-${{ env.CABAL_CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} | ||
|
||
- uses: actions/cache@v3 | ||
name: "Cache `dist-newstyle`" | ||
with: | ||
path: | | ||
dist-newstyle | ||
!dist-newstyle/**/.git | ||
key: cache-dist-${{ env.CABAL_CACHE_VERSION }}-${{ env.DIST_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project') }} | ||
restore-keys: cache-dist-${{ env.CABAL_CACHE_VERSION }}-${{ env.DIST_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} | ||
|
||
- name: Build dependencies | ||
run: cabal build --only-dependencies all -j | ||
|
||
- uses: actions/cache/save@v3 | ||
name: "Save cache: `cabal store`" | ||
with: | ||
path: ${{ steps.setup-haskell.outputs.cabal-store }} | ||
key: cache-dependencies-${{ env.CABAL_CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} | ||
|
||
- name: Build projects [build] | ||
run: cabal build all -j | ||
|
||
# Run benchmarks | ||
- name: Run benchmark script | ||
run: ./scripts/ci/run-miniprotocol-codec-benchmarks.sh ${{ runner.os }} ${{ matrix.ghc-version }} | ||
|
||
# Commit and push baseline file if it was created or updated | ||
- name: Commit baseline file | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add benchmarks/baseline-${{ runner.os }}-${{ matrix.ghc-version }}.csv | ||
git commit -m "Update benchmark baseline for GHC ${{ matrix.ghc-version }} on ${{ runner.os }}" || exit 0 | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Check for correct number of arguments | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 <machine> <ghc-version>" | ||
exit 1 | ||
fi | ||
|
||
# Assign arguments to variables | ||
machine=$1 | ||
ghc_version=$2 | ||
|
||
# Define the filename | ||
baseline="benchmarks/baseline-${machine}-8.10.7.csv" | ||
filename="benchmarks/baseline-${machine}-${ghc_version}.csv" | ||
|
||
# Check if the file exists | ||
if [ -f "$filename" ] && [ -f "$baseline" ]; then | ||
# If file exists, run with baseline results file | ||
echo "Running benchmarks with baseline..." | ||
cabal run ouroboros-network-protocols:bench -- --baseline "$baseline" --fail-if-slower 5 | ||
else | ||
# If file does not exist, run to create baseline file | ||
echo "Running benchmarks to create baseline..." | ||
cabal run ouroboros-network-protocols:bench -- --csv "$filename" | ||
fi | ||
|