Skip to content

Commit be64920

Browse files
Capture profile for keynote bench in nightly job
1 parent cb92b6f commit be64920

2 files changed

Lines changed: 158 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,11 @@ jobs:
273273
runs-on: spacetimedb-benchmark-runner
274274
timeout-minutes: 60
275275
env:
276-
CARGO_TARGET_DIR: ${{ github.workspace }}/target
277276
RUST_BACKTRACE: full
277+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
278+
CARGO_PROFILE_RELEASE_DEBUG: line-tables-only
279+
KEYNOTE_PROFILE_DIR: ${{ github.workspace }}/keynote-profile
280+
STDB_V8_FLAGS: "--perf-basic-prof --perf-basic-prof-only-functions --interpreted-frames-native-stack"
278281
steps:
279282
- name: Find Git ref
280283
env:
@@ -306,7 +309,14 @@ jobs:
306309
prefix-key: v1
307310

308311
- name: Build keynote benchmark binaries
309-
run: cargo build --release -p spacetimedb-cli -p spacetimedb-standalone
312+
run: >
313+
cargo
314+
--config 'build.rustflags = ["-C", "force-frame-pointers=yes"]'
315+
build
316+
--release
317+
-p spacetimedb-cli
318+
-p spacetimedb-standalone
319+
--features spacetimedb-standalone/perfmap
310320
311321
# Node 24 is the current Active LTS line.
312322
- name: Set up Node.js
@@ -323,7 +333,44 @@ jobs:
323333
working-directory: crates/bindings-typescript
324334

325335
- name: Run keynote-2 benchmark regression check
326-
run: cargo ci keynote-bench
336+
id: keynote_bench
337+
run: |
338+
mkdir -p "$KEYNOTE_PROFILE_DIR"
339+
set +e
340+
samply record \
341+
--save-only \
342+
--unstable-presymbolicate \
343+
--profile-name keynote-bench \
344+
-o "$KEYNOTE_PROFILE_DIR/profile.json.gz" \
345+
-- cargo ci keynote-bench
346+
status=$?
347+
ls -lh "$KEYNOTE_PROFILE_DIR" || true
348+
exit "$status"
349+
350+
- name: Upload keynote benchmark profile
351+
if: failure() && steps.keynote_bench.outcome == 'failure'
352+
uses: actions/upload-artifact@v4
353+
with:
354+
name: keynote-bench-profile
355+
path: ${{ env.KEYNOTE_PROFILE_DIR }}
356+
if-no-files-found: warn
357+
retention-days: 14
358+
359+
- name: Report keynote benchmark profile instructions
360+
if: failure() && steps.keynote_bench.outcome == 'failure'
361+
run: |
362+
{
363+
echo "## Keynote benchmark profile"
364+
echo
365+
echo "The keynote benchmark failed after recording a Samply/Firefox profile."
366+
echo
367+
echo "1. Open this run's Summary page: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
368+
echo "2. Download the artifact named \`keynote-bench-profile\`."
369+
echo "3. Open <https://profiler.firefox.com/> and load \`profile.json.gz\`."
370+
echo "4. Compare hot frames against a recent nightly \`keynote-bench-nightly-profile\` artifact."
371+
} >> "$GITHUB_STEP_SUMMARY"
372+
373+
echo "::error title=Keynote benchmark profile uploaded::Download the keynote-bench-profile artifact from this run and open profile.json.gz in https://profiler.firefox.com/."
327374
328375
lints:
329376
name: Lints
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Keynote Bench Nightly
2+
3+
on:
4+
schedule:
5+
# Nightly at 3 AM UTC.
6+
- cron: '0 3 * * *'
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: "Git ref to benchmark"
11+
required: false
12+
default: master
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: keynote-bench-nightly
19+
cancel-in-progress: true
20+
21+
jobs:
22+
keynote_bench:
23+
name: Keynote Bench
24+
runs-on: spacetimedb-benchmark-runner
25+
timeout-minutes: 60
26+
env:
27+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
28+
CARGO_PROFILE_RELEASE_DEBUG: line-tables-only
29+
KEYNOTE_PROFILE_DIR: ${{ github.workspace }}/keynote-profile
30+
STDB_V8_FLAGS: "--perf-basic-prof --perf-basic-prof-only-functions --interpreted-frames-native-stack"
31+
steps:
32+
- name: Checkout sources
33+
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ github.event.inputs.ref || 'master' }}
36+
37+
- uses: dsherret/rust-toolchain-file@v1
38+
- name: Set default rust toolchain
39+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
40+
41+
- name: Cache Rust dependencies
42+
uses: Swatinem/rust-cache@v2
43+
with:
44+
workspaces: ${{ github.workspace }}
45+
shared-key: spacetimedb
46+
save-if: false
47+
prefix-key: v1
48+
49+
- name: Build keynote benchmark binaries
50+
run: >
51+
cargo
52+
--config 'build.rustflags = ["-C", "force-frame-pointers=yes"]'
53+
build
54+
--release
55+
-p spacetimedb-cli
56+
-p spacetimedb-standalone
57+
--features spacetimedb-standalone/perfmap
58+
59+
# Node 24 is the current Active LTS line.
60+
- name: Set up Node.js
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: 24
64+
65+
- uses: ./.github/actions/setup-pnpm
66+
with:
67+
run_install: true
68+
69+
- name: Build TypeScript SDK
70+
run: pnpm build
71+
working-directory: crates/bindings-typescript
72+
73+
- name: Run keynote-2 benchmark regression check
74+
id: keynote_bench
75+
run: |
76+
mkdir -p "$KEYNOTE_PROFILE_DIR"
77+
samply record \
78+
--save-only \
79+
--unstable-presymbolicate \
80+
--profile-name keynote-bench-nightly \
81+
-o "$KEYNOTE_PROFILE_DIR/profile.json.gz" \
82+
-- cargo ci keynote-bench
83+
ls -lh "$KEYNOTE_PROFILE_DIR" || true
84+
85+
- name: Upload keynote benchmark profile
86+
if: always()
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: keynote-bench-nightly-profile
90+
path: ${{ env.KEYNOTE_PROFILE_DIR }}
91+
if-no-files-found: warn
92+
retention-days: 90
93+
94+
- name: Report keynote benchmark profile instructions
95+
if: failure() && steps.keynote_bench.outcome == 'failure'
96+
run: |
97+
{
98+
echo "## Keynote benchmark profile"
99+
echo
100+
echo "The nightly keynote benchmark failed after recording a Samply/Firefox profile."
101+
echo
102+
echo "1. Open this run's Summary page: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
103+
echo "2. Download the artifact named \`keynote-bench-nightly-profile\`."
104+
echo "3. Open <https://profiler.firefox.com/> and load \`profile.json.gz\`."
105+
echo "4. Compare hot frames against earlier nightly \`keynote-bench-nightly-profile\` artifacts."
106+
} >> "$GITHUB_STEP_SUMMARY"
107+
108+
echo "::error title=Keynote benchmark profile uploaded::Download the keynote-bench-nightly-profile artifact from this run and open profile.json.gz in https://profiler.firefox.com/."

0 commit comments

Comments
 (0)