-
Notifications
You must be signed in to change notification settings - Fork 70
209 lines (180 loc) · 6.96 KB
/
regression-check.yml
File metadata and controls
209 lines (180 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: PERF
on:
workflow_dispatch:
pull_request:
# References:
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#reusable-workflows-and-starter-workflows
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_call
# https://docs.github.com/en/actions/learn-github-actions/contexts#about-contexts-and-expressions
# You can override the default DIFF_CUTOFF_PERCENT by specifying a cutoff along
# with the benchmark target.
# Eg, "Data.Async:12" where "Data.Async" is the benchmark target, ":" is the
# seperator, and "12" is the new cutoff percent
#----------------------------------------------------------------------
#-- Benchmarks listed in alphabetical order
#----------------------------------------------------------------------
# Removed Data.Fold.Prelude - was failing for some reason (memory issue?)
jobs:
build:
name: "Comparison: master vs PR (ubuntu-latest ghc-9.14.1)"
env:
GHCVER: 9.14.1
GHCUP_VERSION: 0.1.50.2
CI_BENCHMARKS_WITH_CUTOFF: >-
Data.Array
Data.Array.Generic
Data.Array.Stream
Data.Fold
Data.Fold.Window
Data.MutArray
Data.Parser
Data.ParserK
Data.ParserK.Chunked
Data.ParserK.Chunked.Generic
Data.RingArray
Data.Scanl
Data.Scanl.Concurrent
Data.Scanl.Window
Data.Serialize
Data.Stream
Data.Stream.Concurrent
Data.Stream.ConcurrentEager
Data.Stream.ConcurrentInterleaved
Data.Stream.ConcurrentOrdered
Data.Stream.Prelude
Data.StreamK:6
Data.Unbox
Data.Unbox.Derive.TH
Data.Unfold
Data.Unfold.Prelude
FileSystem.DirIO
FileSystem.Handle
Unicode.Parser
Unicode.Stream
CI_FIELDS: allocated
CI_DIFF_CUTOFF_PERCENT: 3
runs-on: ubuntu-latest
steps:
- name: Checkout the PR branch
uses: actions/checkout@v4
# This should happen before cache restore.
- name: Remove ~/.ghcup symlink
run: |
rm -f ~/.ghcup
- name: Cache ghcup and ghc (non-Windows)
uses: actions/cache@v4
if: runner.os != 'Windows'
with:
path: |
~/.ghcup
key: ${{ runner.os }}-ghcup-${{ env.GHCUP_VERSION }}-${{ env.GHCVER }}
- name: Cache hackage package index (non-Windows)
uses: actions/cache@v4
if: runner.os != 'Windows'
with:
path: |
~/.cache/cabal/packages
# Bump the key version to clear the cache
key: cache-cabal-packages
- name: Cache cabal build dependencies (non-Windows)
uses: actions/cache@v4
if: runner.os != 'Windows'
with:
path: |
~/.local/state/cabal
# Bump the key version to clear the cache
key: performance-comparison-deps
- name: Update CI_BENCHMARKS environment variable
run: |
CI_BENCHMARKS=""
for i in $CI_BENCHMARKS_WITH_CUTOFF
do
bname=$(echo "$i" | cut -d: -f1)
CI_BENCHMARKS="$CI_BENCHMARKS $bname"
done
echo "CI_BENCHMARKS=$CI_BENCHMARKS" >> $GITHUB_ENV
# Use a sane PATH, especially to pick the right GHC
- name: Set PATH to add .local and .ghcup
run: echo "$HOME/.local/bin:$HOME/.ghcup/bin:/bin:/usr/bin" > $GITHUB_PATH
- name: Download ghc
run: |
if ! ghc --version 2>/dev/null | grep -q "$GHCVER"
then
curl -sL -o ./ghcup https://downloads.haskell.org/~ghcup/$GHCUP_VERSION/x86_64-linux-ghcup-$GHCUP_VERSION
chmod +x ./ghcup
export GHCUP_INSTALL_BASE_PREFIX=$HOME
./ghcup install ghc $GHCVER
./ghcup set ghc $GHCVER
./ghcup install cabal
fi
# XXX update only if not present
cabal update
- name: Install bench-runner from PR branch
run: |
cabal install bench-runner --project-file=cabal.project.report --installdir=./ --allow-newer
# -----------------------------------------------------------------
# -- Generate reports for the base branch and upload
# -----------------------------------------------------------------
- name: Checkout the "master" branch
uses: actions/checkout@v4
with:
ref: master
clean: false
- name: Run benchmarks for "master" branch
run: |
# --cabal-build-options "-j1"
./bench-runner --package-name streamly-benchmarks --package-version 0.0.0 --targets "$CI_BENCHMARKS" --raw
# XXX Print dependencies of streamly-core and streamly for comparison
# in case there is a regression due to version changes.
# ghc-pkg --package-db=./dist-newstyle/packagedb/ghc-9.10.3/ field streamly depends
# -----------------------------------------------------------------
# -- Download, generate reports for the current branch and append
# -----------------------------------------------------------------
- name: Checkout the PR branch
uses: actions/checkout@v4
with:
# preserve bench-runner and the "charts" directory created by bench-runner
clean: false
- name: Run benchmarks and append
run: |
# --cabal-build-options "-j1"
./bench-runner --package-name streamly-benchmarks --package-version 0.0.0 --targets "$CI_BENCHMARKS" --raw --append
# -----------------------------------------------------------------
# -- Compare
# -----------------------------------------------------------------
- name: List all benchmarks
run: |
./bench-runner --package-name streamly-benchmarks --package-version 0.0.0 --targets "$CI_BENCHMARKS" --no-measure
- name: Compare benchmarks
run: |
EXIT_STATUS=0
for i in $CI_BENCHMARKS_WITH_CUTOFF
do
arrI=(${i//:/ })
bname=${arrI[0]}
cutoff=${arrI[1]}
test -z "$cutoff" && cutoff=$CI_DIFF_CUTOFF_PERCENT
echo
echo "Checking $bname for regressions greater than $cutoff percent"
! ./bench-runner \
--package-name streamly-benchmarks \
--package-version 0.0.0 \
--targets "$bname" \
--fields "$CI_FIELDS" \
--no-measure --silent \
--diff-cutoff-percent $cutoff \
| grep -v "^$"
test $? -eq 1 && EXIT_STATUS=1
done
# Always exit with success so that we are able to use the cache
echo
echo "------------------------------------------------------------------------"
if test $EXIT_STATUS -ne 0
then
echo "ERROR: Performance regressions are more than ${CI_DIFF_CUTOFF_PERCENT}%."
else
echo "SUCCESS: Performance regressions are within ${CI_DIFF_CUTOFF_PERCENT}%."
fi
echo "------------------------------------------------------------------------"
exit 0