Repository navigation
94 lines (90 loc) · 3.89 KB
/
Copy pathperformance-reference.yml
File metadata and controls
94 lines (90 loc) · 3.89 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
name: FFF performance reference
on:
schedule:
- cron: '7 4 * * *'
workflow_dispatch:
permissions: {}
defaults:
run:
shell: bash
jobs:
reference:
if: github.repository == 'dmtrKovalenko/fff' && github.ref == 'refs/heads/main'
runs-on: [self-hosted, linux, x64, fff-perf-load]
timeout-minutes: 45
permissions:
issues: write
steps:
- name: Measure the saved reference
id: timings
run: |
script="$RUNNER_TEMP/benchmark.sh"
output="$RUNNER_TEMP/fff-results"
reference="$HOME/.local/share/fff-perf/core-reference-native"
mkdir -p "$output"
(
curl -fsSL "https://raw.githubusercontent.com/dmtrKovalenko/fff/$GITHUB_SHA/perf/benchmark.sh" -o "$script" || exit 1
problem=
if [[ ! -r "$reference/script.sha256" ]]; then
problem='The saved reference is missing. Run FFF performance to calibrate.'
elif [[ $(sha256sum "$script" | cut -d' ' -f1) != "$(<"$reference/script.sha256")" ]]; then
problem='The benchmark script changed. Archive the saved reference and recalibrate.'
fi
if [[ -n "$problem" ]]; then
printf '%s\n' "$problem" | tee "$output/reference-error.txt" >&2
exit 1
fi
bash "$script" reference "$output"
) 2>&1 | tee "$output/benchmark.log"
- name: Publish reference result
if: ${{ !cancelled() }}
env:
GH_TOKEN: ${{ github.token }}
MEASURE: ${{ steps.timings.outcome }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
report="$RUNNER_TEMP/fff-reference.md"
results="$RUNNER_TEMP/fff-results"
if [[ "$MEASURE" == success ]]; then
if awk '
NR == FNR { base[$2] = $5; next }
10 * $5 > 11 * base[$2] || 10 * $5 < 9 * base[$2] {
if (!rows++) print "| Benchmark | Baseline (ns) | Measured (ns) | Change |\n| --- | ---: | ---: | ---: |"
printf "| `%s` | %d | %d | %+.2f%% |\n", $2, base[$2], $5, 100 * ($5 / base[$2] - 1)
}
END { exit (rows > 0) }
' "$results/base.bench" "$results/head.bench" >"$report"; then
echo 'FFF core reference is within 10%' >>"$GITHUB_STEP_SUMMARY"
exit 0
fi
title='FFF benchmark reference drift'
else
title='FFF benchmark reference failed'
if [[ -s "$results/reference-error.txt" ]]; then
cp "$results/reference-error.txt" "$report"
else
echo 'FFF core measurement could not complete. See the fff-measurements artifact for the log.' >"$report"
fi
fi
printf '\n[Workflow run](%s)\n' "$RUN_URL" >>"$report"
cat "$report" >>"$GITHUB_STEP_SUMMARY"
issue=$(gh issue list -R "$GITHUB_REPOSITORY" --state open --author 'github-actions[bot]' \
--search "$title in:title" --json number,title |
jq -r --arg title "$title" 'first(.[] | select(.title == $title) | .number) // empty')
if [[ -n "$issue" ]]; then
gh issue comment "$issue" -R "$GITHUB_REPOSITORY" --body-file "$report"
else
gh issue create -R "$GITHUB_REPOSITORY" --title "$title" --body-file "$report" --assignee "$GITHUB_REPOSITORY_OWNER"
fi
exit 1
- name: Upload reference logs and timings
if: ${{ !cancelled() && (steps.timings.outcome == 'success' || steps.timings.outcome == 'failure') }}
uses: actions/upload-artifact@v7
with:
name: fff-measurements
path: |
${{ runner.temp }}/fff-results/*.bench
${{ runner.temp }}/fff-results/benchmark.log
if-no-files-found: error
retention-days: 30
overwrite: true