-
Notifications
You must be signed in to change notification settings - Fork 57
150 lines (140 loc) · 5.33 KB
/
bench.yml
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
name: bench
permissions:
contents: write
on:
# push:
# branches:
# - main
workflow_dispatch:
inputs:
index:
description: 'Benchmark index'
required: false
default: 'default'
selector:
description: 'Benchmark selector'
required: false
default: 'Kyo'
warmupIterations:
description: 'Warmup iterations'
required: false
default: '10'
measurementIterations:
description: 'Measurement iterations'
required: false
default: '4'
iterationTime:
description: 'Iteration time'
required: false
default: '1'
forks:
description: 'Number of forks'
required: false
default: '1'
threads:
description: 'Number of threads'
required: false
default: '1'
profileEvents:
description: 'Profile events'
required: false
default: 'alloc,cpu'
jobs:
bench:
name: bench
runs-on: bench
timeout-minutes: 240
env:
IX: ${{ github.event.inputs.index || 'default' }}
SE: ${{ github.event.inputs.selector || 'Kyo' }}
WI: ${{ github.event.inputs.warmupIterations || '13' }}
MI: ${{ github.event.inputs.measurementIterations || '5' }}
IT: ${{ github.event.inputs.iterationTime || '1' }}
FK: ${{ github.event.inputs.forks || '1' }}
TH: ${{ github.event.inputs.threads || '1' }}
PE: ${{ github.event.inputs.profileEvents || 'alloc,cpu' }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: coursier/cache-action@v6
- uses: olafurpg/setup-scala@v13
with:
java-version: [email protected]=tgz+https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-x64_bin.tar.gz
- name: install async-profiler
run: |
cd /home/runner
wget https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/async-profiler-2.9-linux-x64.tar.gz
tar -xvzf async-profiler-2.9-linux-x64.tar.gz
sudo mkdir -p /usr/java/packages/lib/
sudo cp async-profiler-2.9-linux-x64/build/libasyncProfiler.so /usr/java/packages/lib/
sudo sysctl kernel.perf_event_paranoid=1
sudo sysctl kernel.kptr_restrict=0
- name: run
run: |
IFS=', ' read -r -a array <<< "$PE"
for EVENT in "${array[@]}"
do
ESCAPED_EVENT=$(printf '%q' "$EVENT")
sbt "kyo-bench/jmh:clean;kyo-bench/jmh:run -wi $WI -i $MI -r $IT -w $IT -f $FK -t $TH -foe true -prof \"async:event=$ESCAPED_EVENT;output=flamegraph\" $SE"
done
sbt "kyo-bench/jmh:clean;kyo-bench/jmh:run -wi $WI -i $MI -r $IT -w $IT -f $FK -t $TH -foe true -prof gc -rf json $SE"
- name: prepare results
run: |
short_sha=$(echo "${{ github.sha }}" | cut -c 1-7)
mkdir -p output/
cp -r kyo-bench/.jvm/jmh-result.json output/#${short_sha}-jmh-result.json
cp -r kyo-bench/.jvm/kyo.bench.* output/
rm -rf output/**/*reverse.html
for file in $(find output -name "*.html"); do
newfile=$(echo $file | sed 's/\([^.]*\)-.*flame-\([^-]*\)-forward.html/\1-\2.html/')
if [ "$file" != "$newfile" ]; then
mv "$file" "$newfile"
fi
done
for file in $(find output -name "*.html"); do
new_name="${short_sha}-$(basename "$file")"
mv "$file" "$(dirname "$file")/$new_name"
done
ls output/
- name: publish results
id: publish-results
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs').promises;
const path = require('path');
const short_sha = context.sha.substring(0, 7);
const tag = `bench-${short_sha}`;
const date = new Date().toISOString().split('T')[0];
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: `Benchmark Results ${short_sha} ${date}`,
body: `Benchmark results for commit ${context.sha} on ${date}`,
prerelease: true
});
async function* getFiles(dir) {
const entries = await fs.readdir(dir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
yield* getFiles(fullPath);
} else {
yield fullPath;
}
}
}
for await (const filePath of getFiles('output')) {
const content = await fs.readFile(filePath);
const fileName = path.basename(filePath);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: fileName,
data: content
});
}