Skip to content

Commit 6cc31ee

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
test(design-diff): replay frozen schema 3 benchmark in isolated cloud shards
1 parent 777a4aa commit 6cc31ee

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Design diff frozen benchmark
2+
3+
on:
4+
push:
5+
branches: [codex/design-diff-benchmark-v3]
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: design-diff-benchmark-v3
12+
cancel-in-progress: true
13+
14+
env:
15+
ENGINE_SHA: 777a4aa4b303d3e06aa652818b068ac3374bfa28
16+
17+
jobs:
18+
replay:
19+
runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}
20+
timeout-minutes: 60
21+
strategy:
22+
fail-fast: false
23+
max-parallel: 8
24+
matrix:
25+
shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
26+
steps:
27+
- name: Checkout immutable engine
28+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
29+
with:
30+
ref: ${{ env.ENGINE_SHA }}
31+
path: engine
32+
fetch-depth: 0
33+
persist-credentials: false
34+
- name: Checkout benchmark driver
35+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
36+
with:
37+
ref: ${{ github.sha }}
38+
path: driver
39+
persist-credentials: false
40+
- name: Setup Bun
41+
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
42+
with:
43+
bun-version: 1.4.1
44+
- name: Install trusted dependencies
45+
working-directory: engine
46+
run: bun install --frozen-lockfile --ignore-scripts
47+
- name: Freeze shard and fetch source as data
48+
env:
49+
SHARD: ${{ matrix.shard }}
50+
GH_TOKEN: ${{ github.token }}
51+
run: bun --no-env-file driver/scripts/design-diff/cloud-benchmark.ts
52+
- name: Replay frozen comparisons
53+
working-directory: engine
54+
run: |
55+
bun --no-env-file scripts/design-diff/benchmark.ts \
56+
--engine "$PWD" --sha "$ENGINE_SHA" --workers 1 \
57+
--manifest "$RUNNER_TEMP/comparisons.json" --output "$RUNNER_TEMP/results"
58+
- name: Retain available results
59+
if: always()
60+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
61+
with:
62+
name: design-benchmark-${{ env.ENGINE_SHA }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.shard }}
63+
path: ${{ runner.temp }}/results/
64+
retention-days: 7
65+
if-no-files-found: error
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { execFileSync } from 'node:child_process'
2+
import { readFileSync, writeFileSync } from 'node:fs'
3+
import path from 'node:path'
4+
5+
/** Prepare a deterministic shard from the pinned engine's frozen manifest. */
6+
try {
7+
const engine = path.resolve('engine')
8+
const manifest = JSON.parse(
9+
readFileSync(path.join(engine, 'scripts/design-diff/benchmark/comparisons.json'), 'utf8')
10+
)
11+
const shard = Number(process.env.SHARD)
12+
if (!Number.isInteger(shard) || shard < 0 || shard >= 20) throw new Error('Invalid shard')
13+
manifest.comparisons = manifest.comparisons.filter(
14+
(entry: { sampleOrder: number }) => entry.sampleOrder % 20 === shard
15+
)
16+
const commits = [
17+
...new Set<string>(
18+
manifest.comparisons.flatMap((entry: { base: string; head: string }) => [
19+
entry.base,
20+
entry.head,
21+
])
22+
),
23+
]
24+
if (commits.some((commit) => !/^[a-f0-9]{40}$/.test(commit))) throw new Error('Invalid revision')
25+
writeFileSync(
26+
path.join(process.env.RUNNER_TEMP!, 'comparisons.json'),
27+
`${JSON.stringify(manifest, null, 2)}\n`
28+
)
29+
const authorization = Buffer.from(`x-access-token:${process.env.GH_TOKEN}`).toString('base64')
30+
execFileSync(
31+
'git',
32+
[
33+
'-c',
34+
`http.extraheader=AUTHORIZATION: basic ${authorization}`,
35+
'fetch',
36+
'--no-tags',
37+
'origin',
38+
...commits,
39+
],
40+
{ cwd: engine, stdio: 'ignore' }
41+
)
42+
process.stdout.write(
43+
`Prepared shard ${shard}: ${manifest.comparisons.length} frozen comparisons\n`
44+
)
45+
} catch {
46+
process.stderr.write('Benchmark shard preparation failed; no source code was executed.\n')
47+
process.exitCode = 1
48+
}

0 commit comments

Comments
 (0)