Skip to content

Commit 909a9cb

Browse files
andreiburdusattuegelrv-jenkins
authored
Run EVM tests with --rts-statistics and collect the results (#2533)
* Run tests with --rts-statistics and collect the results * test-statistics.sh: Output a CSV file for easy manipulation * Add scripts/join-statistics.sh * Allow running test-statistics.sh from test.nix shell * Add Performance workflow * Do not run Performance workflow on macOS * Fix statistics script invocation * Pull from runtimeverification in Performance workflow * Use test.nix for running test-statistics.sh * Use nix/shell.performance.nix for performance testing * Fetch from origin in Performance workflow * test-statistics.sh: Build own kore-exec * test-statistics.sh: Build kore-exec from other trees * Use test.nix for running test-statistics.sh * Use tabular JSON format * Fix path to test-statistics.sh * Comment on pull request with performance data * Use CSV for intermediate tables * Integrate performance testing into Test workflow * test-statistics.sh: accept multiple test directories * test.yml: Test wasm-semantics, too Co-authored-by: Thomas Tuegel <[email protected]> Co-authored-by: Thomas Tuegel <[email protected]> Co-authored-by: rv-jenkins <[email protected]>
1 parent 1fede2c commit 909a9cb

File tree

5 files changed

+93
-1
lines changed

5 files changed

+93
-1
lines changed

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,49 @@ jobs:
214214

215215
- name: Run hlint
216216
run: curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s kore -j
217+
218+
performance:
219+
needs: [nix-build]
220+
name: 'Performance'
221+
runs-on: ubuntu-latest
222+
steps:
223+
- name: Check out code
224+
uses: actions/[email protected]
225+
with:
226+
# Check out pull request HEAD instead of merge commit.
227+
ref: ${{ github.event.pull_request.head.sha }}
228+
submodules: recursive
229+
230+
- name: Install Nix
231+
uses: cachix/install-nix-action@v12
232+
with:
233+
extra_nix_config: |
234+
substituters = http://cache.nixos.org https://hydra.iohk.io
235+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
236+
237+
- name: Install Cachix
238+
uses: cachix/cachix-action@v8
239+
with:
240+
name: kore
241+
extraPullNames: runtimeverification
242+
signingKey: '${{ secrets.KORE_CACHIX_SIGNING_KEY }}'
243+
skipPush: true
244+
245+
- name: Collect performance statistics
246+
env:
247+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
248+
run: |
249+
./scripts/test-statistics.sh ./. \
250+
test/regression-evm \
251+
test/regression-wasm \
252+
> pull-request.json
253+
git fetch origin
254+
git worktree add kore-master master
255+
./scripts/test-statistics.sh ./kore-master \
256+
test/regression-evm \
257+
test/regression-wasm \
258+
> master.json
259+
./scripts/join-statistics.sh master.json pull-request.json \
260+
| ./scripts/format-statistics.sh \
261+
> comment.md
262+
gh pr comment ${{ github.event.pull_request.number }} -F comment.md

scripts/format-statistics.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell ../test.nix -i bash
3+
4+
mlr --icsv --omd cut -o -f name,allocated_bytes,diff_allocated_bytes,max_live_bytes,diff_max_live_bytes

scripts/join-statistics.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell ../test.nix -i bash
3+
4+
old=${1:?}; shift
5+
new=${1:?}; shift
6+
7+
# 1. Join the statistics files by row according to name.
8+
# Give the columns from each file a unique prefix.
9+
# 2. Add a column for the (relative) difference between old and new values.
10+
mlr --ijson --ocsv join -j name --lp old_ --rp new_ -f "$old" "$new" \
11+
| mlr --csv put '$diff_allocated_bytes = ($new_allocated_bytes - $old_allocated_bytes) / $old_allocated_bytes' \
12+
| mlr --csv put '$diff_max_live_bytes = ($new_max_live_bytes - $old_max_live_bytes) / $old_max_live_bytes'

scripts/test-statistics.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell ../test.nix -i bash
3+
4+
# Usage: test-statistics.sh KORE_DIR TEST_DIR TEST_DIR ...
5+
# Output: tabular JSON on standard output
6+
7+
set -eou pipefail
8+
9+
kore_dir="${1:?}"; shift
10+
export KORE_EXEC="$(nix-build "$kore_dir" -A kore --arg release true --no-out-link)/bin/kore-exec"
11+
12+
while [[ $# -gt 0 ]]
13+
do
14+
test_dir="${1:?}"; shift
15+
(
16+
cd "$test_dir"
17+
for each in $(find ./ -name 'test-*.sh')
18+
do
19+
json="${each%sh}.json"
20+
"${each}" --rts-statistics "$json" >/dev/null
21+
jq ". | { name: \"$test_dir${each#.}\", allocated_bytes: .allocated_bytes, max_live_bytes: .max_live_bytes }" < "$json"
22+
rm "$json"
23+
done
24+
)
25+
done
26+
27+
28+

test.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ in
99

1010
let
1111
inherit (pkgs) stdenv lib;
12-
inherit (pkgs) bison diffutils ncurses z3;
12+
inherit (pkgs) bison diffutils jq miller ncurses z3;
1313

1414
ttuegel =
1515
let
@@ -44,11 +44,13 @@ stdenv.mkDerivation {
4444
buildInputs = [
4545
k kore # some tests use kore-exec directly, others run through the frontend
4646
ncurses # TODO: .../lib/kframework/setenv: line 31: tput: command not found
47+
jq miller # processing test statistics
4748
z3
4849
];
4950
configurePhase = ''
5051
export TOP=$(pwd)
5152
'';
53+
KORE_EXEC = "${lib.getBin kore}/bin/kore-exec";
5254
buildFlags =
5355
[
5456
"KORE_PARSER=kore-parser"

0 commit comments

Comments
 (0)