forked from microsoft/hcsshim
-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (152 loc) · 5.61 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Benchmark
on:
pull_request:
# branches: [main]
paths-ignore:
- "**/*.md"
- "**/*.txt"
- "hack/**"
- "scripts/**"
- ".github/**"
defaults:
run:
shell: pwsh
env:
GO_VERSION: "1.19.x"
GO_BUILD_TEST_CMD: "go test -mod=mod -gcflags=all=-d=checkptr -c -tags functional"
# NOTE: Merge branch is ${{ github.ref }} (at ${{ github.sha}}), merging into ${{ github.base_ref }}
jobs:
benchmark:
name: Run Functional Benchmarks
env:
BENCH_FILE: "${{ matrix.name }}_bench.txt"
# TEST_COUNT: "10"
# BENCH_TIME: "50x"
TEST_COUNT: "1"
BENCH_TIME: "5s"
strategy:
fail-fast: false
matrix:
os: [windows-2019]
# os: [windows-2019, windows-2022] # TODO
ref: ["${{ github.ref }}", "${{ github.base_ref }}"]
include:
# add names to identify the instance (mostly because branch names are potentially invalid artifact names)
- ref: "${{ github.ref }}"
name: "pr"
- ref: "${{ github.base_ref }}"
name: "base"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout ${{ matrix.ref}}
uses: actions/checkout@v4
with:
ref: "${{ matrix.ref }}"
show-progress: false
- name: Install go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: |
go.sum
test/go.sum
- name: Install benchstat
run: |
go install golang.org/x/perf/cmd/benchstat@latest
# Download PsExec so we can run (functional) tests as 'NT Authority\System'.
# Needed for hostprocess tests, as well ensuring backup and restore privileges for
# unpacking WCOW images.
- name: Install PsExec.exe
run: |
New-Item -ItemType Directory -Force '${{ github.workspace }}\bin' > $null
'${{ github.workspace }}\bin' | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
curl.exe -L --no-progress-meter --fail-with-body -o 'C:\PSTools.zip' `
'https://download.sysinternals.com/files/PSTools.zip' 2>&1
if ( $LASTEXITCODE ) {
Write-Output '::error::Could not download PSTools.zip'
exit $LASTEXITCODE
}
tar.exe xf 'C:\PSTools.zip' -C '${{ github.workspace }}\bin' 'PsExec*' 2>&1
if ( $LASTEXITCODE ) {
Write-Output '::error::Could not extract PsExec.exe'
exit $LASTEXITCODE
}
# accept the eula
& '${{ github.workspace }}/bin/psexec' -accepteula -nobanner cmd /c "exit 0" 2>$null
- name: Set version info
run: |
# ignore errors since they won't affect build
try {
./scripts/Set-VersionInfo.ps1
} catch {
Write-Output "::warning::Could not set hcsshim version info: $_"
} finally {
$LASTEXITCODE = 0
}
- name: Build functional benchmarks
working-directory: test
run: ${{ env.GO_BUILD_TEST_CMD }} ./functional
- name: Run functional benchmarks
working-directory: test
continue-on-error: true # allow results to be processes below
timeout-minutes: 60 # `-test.timeout` flag doesn't apply to benchmarks
run: |
# don't run uVM (ie, nested virt) or LCOW integrity tests
$cmd = 'functional.test.exe -exclude="LCOW,LCOWIntegrity,uVM" ' + `
'-test.shuffle=on -test.run=^^# -test.bench=. -test.benchmem ' + `
'-test.v ' + `
'-test.count=${{ env.TEST_COUNT }} -test.benchtime=${{ env.BENCH_TIME }}'
Write-Output "Benchmark command: $cmd"
# Write benchmarks to file
psexec -nobanner -w (Get-Location) -s cmd /c "$cmd > ${{ env.BENCH_FILE }} 2>&1"
if ( $LASTEXITCODE ) {
Write-Output '::error::Benchmarks failed'
}
- name: Show benchmark results
working-directory: test
run: |
if ( -not (Test-Path -PathType Leaf ${{ env.BENCH_FILE }}) ) {
Write-Output '::error::Benchmarks did not produce any output'
exit 1
}
Write-Output "::group::Benmark results (${{ env.BENCH_FILE }})"
Get-Content -Path "${{ env.BENCH_FILE }}"
Write-Output "::endgroup::"
Write-Output "::group::Benmark statistics"
benchstat -table="" ${{ env.BENCH_FILE }}
Write-Output "::endgroup::"
- uses: actions/upload-artifact@v3
name: Upload benchmark results
with:
name: benchmark_${{ matrix.os }}_${{ matrix.name }}
path: test/${{ env.BENCH_FILE }}
retention-days: 7 # one week, instead of the default 90 days
benchmark-perf:
name: Analyze Functional Benchmarks
needs: [benchmark]
strategy:
fail-fast: false
matrix:
os: [windows-2019]
# os: [windows-2019, windows-2022] # TODO
runs-on: ${{ matrix.os }}
steps:
- name: Download ${{ github.ref }} results
uses: actions/download-artifact@v3
with:
name: benchmark_${{ matrix.os }}_pr
- name: Download ${{ github.base_ref }} results
uses: actions/download-artifact@v3
with:
name: benchmark_${{ matrix.os }}_base
- name: Install go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Install benchstat
run: |
go install golang.org/x/perf/cmd/benchstat@latest
- name: Compare benchmarks
run: |
benchstat -table="" base_bench.txt pr_bench.txt