forked from prisma/prisma-engines
-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (141 loc) Β· 5.6 KB
/
wasm-benchmarks.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: "QE: WASM benchmarks"
on:
pull_request:
paths-ignore:
- ".github/**"
- "!.github/workflows/wasm-benchmarks.yml"
- ".buildkite/**"
- "*.md"
- "LICENSE"
- "CODEOWNERS"
- "renovate.json"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
benchmarks:
runs-on: ubuntu-latest
env: # Set environment variables for the whole job
PROFILE: release
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
# using head ref rather than merge branch to get original commit message
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/workflows/include/rust-wasm-setup
- name: "Setup Node.js"
uses: actions/setup-node@v4
- name: "Setup pnpm"
uses: pnpm/[email protected]
with:
version: 8
- name: "Login to Docker Hub"
uses: docker/login-action@v3
continue-on-error: true
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
if: "${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}"
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Branch Name
run: |
echo "Extracting branch name from: $(git show -s --format=%s)"
branch="$(git show -s --format=%s | grep -o "DRIVER_ADAPTERS_BRANCH=[^ ]*" | cut -f2 -d=)"
echo "branch=$branch"
if [ -n "$branch" ]; then
echo "Using $branch branch of driver adapters"
echo "DRIVER_ADAPTERS_BRANCH=$branch" >> "$GITHUB_ENV"
fi
- name: Setup benchmark
run: make setup-pg-bench
- name: Run benchmarks
id: bench
if: false
run: |
make run-bench | tee results.txt
# Extract the values from the benchmark output
regressed_values=$(grep "slower than Web Assembly: Latest" results.txt | cut -f1 -d'x')
improved_values=$(grep "faster than Web Assembly: Latest" results.txt | cut -f1 -d'x')
# Initialize sum variable and count
total_sum=0
total_count=0
# Add the inverted regressed values to the sum
for value in $regressed_values; do
inverted=$(echo "scale=4; 1/$value" | bc)
echo "Regressed value: $inverted"
total_sum=$(echo "$total_sum + $inverted" | bc)
total_count=$((total_count + 1))
done
# Add the improved values to the sum
for value in $improved_values; do
echo "Improved value: $value"
total_sum=$(echo "$total_sum + $value" | bc)
total_count=$((total_count + 1))
done
if [ $total_count -eq 0 ]; then
echo "π₯ something was wrong running the benchmarks"
exit 1
fi
mean=$(echo "scale=4; $total_sum / $total_count" | bc)
echo "Extracted $total_count values from the benchmark output"
echo "Total sum: $total_sum"
echo "Total count: $total_count"
echo "Mean: $mean"
# Report improvement or worsening. Fails if >= 1.5% worsening.
if (( $(echo "$mean < 0.985" | bc -l) )); then
percent=$(echo "scale=4; ((1 / $mean) - 1) * 100" | bc)
summary="β WASM query-engine performance will worsen by $(printf %.2f "$percent")%"
status=failed
elif (( $(echo "$mean > 1.015" | bc -l) )); then
percent=$(echo "scale=4; ($mean - 1) * 100" | bc)
summary="π WASM query-engine performance will improve by $(printf %.2f "$percent")%"
status=passed
else
delta=$(echo "scale=3; (1 / $mean)" | bc)
summary="β
WASM query-engine performance won't change substantially ($(printf %.3f "$delta")x)"
status=passed
fi
echo "summary=$summary" >> "$GITHUB_OUTPUT"
echo "status=$status" >> "$GITHUB_OUTPUT"
# Save the output to a file so we can use it in the comment
{
echo 'bench_output<<EOF'
cat results.txt
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Find past report comment
if: false
uses: peter-evans/find-comment@v3
id: findReportComment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "<!-- wasm-engine-perf -->"
- name: Create or update report
uses: peter-evans/create-or-update-comment@v4
# Only run on branches from our repository
# It avoids an expected failure on forks
# if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
if: false
with:
comment-id: ${{ steps.findReportComment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- wasm-engine-perf -->
#### ${{ steps.bench.outputs.summary }}
<details>
<summary>Full benchmark report</summary>
```
${{ steps.bench.outputs.bench_output }}
```
</details>
After changes in ${{ github.event.pull_request.head.sha }}
edit-mode: replace
- name: Fail workflow if regression detected
# if: steps.bench.outputs.status == 'failed'
if: false
run: |
echo "Workflow failed due to benchmark regression."
exit 1