-
-
Notifications
You must be signed in to change notification settings - Fork 719
166 lines (146 loc) · 5.35 KB
/
Copy pathperf.yml
File metadata and controls
166 lines (146 loc) · 5.35 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
name: perf
on:
pull_request:
paths-ignore:
- 'spec/**'
- 'changelog/**'
- '**/*.md'
push:
branches: [master]
concurrency:
group: perf-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
perf:
runs-on: ubuntu-24.04
timeout-minutes: 60
env:
OS_NAME: linux
MODEL: 64
FULL_BUILD: false
HOST_DMD: ldc-1.42.0
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set parallelism
run: echo "N=$(nproc)" >> "$GITHUB_ENV"
- name: Compute base/head SHAs
id: refs
run: |
set -uexo pipefail
HEAD_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
echo "head=$HEAD_SHA" >> "$GITHUB_OUTPUT"
echo "branch=${GITHUB_BASE_REF:-master}" >> "$GITHUB_OUTPUT"
# A pushed commit is its own merge-base with master, so nothing
# to diff against there. Measure alone and record it as history.
if [ "${{ github.event_name }}" = pull_request ]; then
git fetch --no-tags origin master
echo "base=$(git merge-base "$HEAD_SHA" origin/master)" >> "$GITHUB_OUTPUT"
else
BEFORE="${{ github.event.before }}"
# All zeroes on the first push to a branch.
git rev-parse -q --verify "$BEFORE^{commit}" > /dev/null || BEFORE="$HEAD_SHA~"
echo "base=" >> "$GITHUB_OUTPUT"
echo "before=$BEFORE" >> "$GITHUB_OUTPUT"
echo "commits=$(git rev-list --count "$BEFORE..$HEAD_SHA")" >> "$GITHUB_OUTPUT"
echo "date=$(TZ=UTC git show -s --format=%cd --date=iso-strict-local "$HEAD_SHA")" >> "$GITHUB_OUTPUT"
fi
- name: Install prerequisites
run: |
sudo apt-get update
sudo apt-get install -y valgrind time
valgrind --version
- name: Install host compiler
run: |
ci/run.sh install_host_compiler
source ~/dlang/*/activate
which ldc-profdata
deactivate
- name: Build dmd at base and head
run: |
set -uexo pipefail
source ~/dlang/*/activate
BASE_SHA="${{ steps.refs.outputs.base }}"
# Check out a ref in an isolated temp dir and clone phobos.
setup_ref() {
local dir="$RUNNER_TEMP/$2/dmd"
mkdir -p "$RUNNER_TEMP/$2"
git worktree add --force "$dir" "$1"
( cd "$dir" && ci/run.sh setup_repos "${{ steps.refs.outputs.branch }}" )
}
# Build LTO+PGO'd dmd, druntime and phobos, Lines are tagged with the ref.
build_ref() {
make -C "$RUNNER_TEMP/$1/dmd" -j$N HOST_DMD=$DMD MODEL=$MODEL dmd-pgo 2>&1 | sed -u "s/^/[$1] /"
}
# Both build in parallel
setup_ref "${{ steps.refs.outputs.head }}" head
if [ -n "$BASE_SHA" ]; then
setup_ref "$BASE_SHA" base
build_ref base & base_pid=$!
fi
build_ref head
if [ -n "$BASE_SHA" ]; then
wait $base_pid
fi
deactivate
- name: Cache dub packages
uses: actions/cache@v6
with:
path: ~/.dub/packages
key: dub-packages-${{ hashFiles('tools/perfrunner/workloads/vibed/dub.selections.json') }}
- name: Measure
run: |
set -uexo pipefail
source ~/dlang/*/activate
built=generated/$OS_NAME/release/$MODEL/dmd
BASE_SHA="${{ steps.refs.outputs.base }}"
args=(
--head-dmd "$RUNNER_TEMP/head/dmd/$built"
--head-phobos "$RUNNER_TEMP/head/phobos"
--head-src "$RUNNER_TEMP/head/dmd"
--head-sha "${{ steps.refs.outputs.head }}"
--os ubuntu-24.04
--host-dmd "$HOST_DMD"
--host-dmd-bin "$DMD"
--out "$GITHUB_WORKSPACE/results.json"
)
if [ -n "$BASE_SHA" ]; then
args+=(
--base-dmd "$RUNNER_TEMP/base/dmd/$built"
--base-phobos "$RUNNER_TEMP/base/phobos"
--base-src "$RUNNER_TEMP/base/dmd"
--base-sha "$BASE_SHA"
--pr "${{ github.event.pull_request.number || 0 }}"
)
else
args+=(
--before "${{ steps.refs.outputs.before }}"
--commits "${{ steps.refs.outputs.commits }}"
--committed-at "${{ steps.refs.outputs.date }}"
)
fi
cd tools/perfrunner
dub run -- "${args[@]}"
- name: Show results
run: cat "$GITHUB_WORKSPACE/results.json"
# perf-comment.yml picks this up and posts the comment.
- name: Upload results
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v7
with:
name: perf-results
path: results.json
- name: Publish to the history repo
if: github.event_name == 'push' && vars.PERF_DATA_REPO != ''
env:
PERF_DATA_REPO: ${{ vars.PERF_DATA_REPO }}
PERF_DATA_KEY: ${{ secrets.PERF_DATA_KEY }}
SHA: ${{ steps.refs.outputs.head }}
COMMITTED_AT: ${{ steps.refs.outputs.date }}
run: .github/scripts/perf_publish.sh "$GITHUB_WORKSPACE/results.json"