forked from w1ne/labwired-core
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (119 loc) · 4.35 KB
/
Copy pathcore-perf.yml
File metadata and controls
133 lines (119 loc) · 4.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
name: Core Perf (simulator throughput)
# Holds per-board simulator throughput still.
#
# The gate measures host instructions retired per simulated CPU step, per
# board, under callgrind — see scripts/perf/board_perf.py for why that metric
# and not wall clock. It is NOT a merge-blocking gate on PRs by default: it
# runs on push to main and nightly, and opens/updates an issue when a board
# regresses, so a slowdown is noticed the day it lands rather than months later
# when someone reports "the blinky looks frozen".
#
# Run it on a PR by hand with workflow_dispatch when touching the CPU step
# path, the machine-advance loop, or the peripheral tick walk.
on:
push:
branches:
- main
paths:
- "crates/core/**"
- "crates/cli/**"
- "crates/config/**"
- "configs/chips/**"
- "crates/firmware-perf-spin/**"
- "scripts/perf/**"
- ".github/workflows/core-perf.yml"
schedule:
# Nightly, after core-ci's 02:30 slot.
- cron: "45 3 * * *"
workflow_dispatch:
concurrency:
group: core-perf-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
issues: write
jobs:
board-throughput:
name: board-throughput
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@1.95.0
with:
targets: thumbv6m-none-eabi
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: core-perf
workspaces: |
. -> target
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install valgrind
run: sudo apt-get update && sudo apt-get install -y valgrind
# The browser ships labwired-core with `event-scheduler` (see
# crates/wasm/Cargo.toml). Measuring without it would gate a build
# configuration no user ever runs.
- name: Build simulator CLI (browser feature set)
run: cargo build --release -p labwired-cli --features event-scheduler
- name: Build perf fixture firmware
run: cargo build -p firmware-perf-spin --release --target thumbv6m-none-eabi
- name: Measure per-board throughput
id: perf
run: |
set -o pipefail
python3 scripts/perf/board_perf.py 2>&1 | tee perf-report.txt
- name: Upload report
if: always()
uses: actions/upload-artifact@v4
with:
name: board-throughput-report
path: perf-report.txt
# A regression is a real product defect (every extra host instruction per
# simulated step slows the browser twin by the same proportion), so it
# gets a tracked issue rather than a red X someone scrolls past.
- name: Open/refresh regression issue
if: failure() && github.event_name != 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('perf-report.txt', 'utf8');
const title = 'Simulator throughput regression (per-board perf gate)';
const body = [
`Commit: ${context.sha}`,
`Run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
'',
'```',
report.slice(-8000),
'```',
'',
'Re-baseline with `python3 scripts/perf/board_perf.py --update` if the cost is intentional.',
].join('\n');
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'perf-regression',
});
const hit = existing.data.find((i) => i.title === title);
if (hit) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: hit.number,
body,
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body,
labels: ['perf-regression'],
});
}