ci(memory): harden benchmark reporting
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { mkdir, readFile, writeFile } from "node:fs/promises"
|
import { mkdtemp, readFile, writeFile } from "node:fs/promises"
|
||||||
import { tmpdir } from "node:os"
|
import { tmpdir } from "node:os"
|
||||||
import { join, resolve } from "node:path"
|
import { join, resolve } from "node:path"
|
||||||
import { execFile, spawn } from "node:child_process"
|
import { execFile, spawn } from "node:child_process"
|
||||||
@@ -26,9 +26,7 @@ const piVersion = process.env.MEMORY_BENCHMARK_PI_VERSION ?? "unknown"
|
|||||||
const runtimeName = process.versions.bun ? "Bun" : "Node"
|
const runtimeName = process.versions.bun ? "Bun" : "Node"
|
||||||
const runtimeVersion = process.versions.bun ?? process.versions.node
|
const runtimeVersion = process.versions.bun ?? process.versions.node
|
||||||
|
|
||||||
const benchmarkDir = await mkdir(join(tmpdir(), `pi-memory-benchmark-${process.pid}`), {
|
const benchmarkDir = await mkdtemp(join(tmpdir(), "pi-memory-benchmark-"))
|
||||||
recursive: true,
|
|
||||||
}).then(() => join(tmpdir(), `pi-memory-benchmark-${process.pid}`))
|
|
||||||
const cachePath = join(benchmarkDir, "commandcode-models.json")
|
const cachePath = join(benchmarkDir, "commandcode-models.json")
|
||||||
await writeFile(
|
await writeFile(
|
||||||
cachePath,
|
cachePath,
|
||||||
@@ -295,6 +293,16 @@ function renderReport(summary, comparisons) {
|
|||||||
})
|
})
|
||||||
.join("\n")
|
.join("\n")
|
||||||
|
|
||||||
|
const clearChanges = metrics
|
||||||
|
.map(([key, label]) => [label, comparisons[key].headMinusBase])
|
||||||
|
.filter(([, estimate]) => Math.abs(estimate.median) > estimate.mad)
|
||||||
|
const interpretation =
|
||||||
|
clearChanges.length === 0
|
||||||
|
? "No metric shows a clear Base-to-PR difference beyond its measured run-to-run variation."
|
||||||
|
: `Differences larger than their measured MAD: ${clearChanges
|
||||||
|
.map(([label, estimate]) => `${label} ${formatSignedEstimate(estimate)}`)
|
||||||
|
.join(", ")}.`
|
||||||
|
|
||||||
const overheadRows = metrics
|
const overheadRows = metrics
|
||||||
.map(([key, label]) => {
|
.map(([key, label]) => {
|
||||||
const comparison = comparisons[key]
|
const comparison = comparisons[key]
|
||||||
@@ -308,6 +316,7 @@ function renderReport(summary, comparisons) {
|
|||||||
`| Metric | Base | PR | PR − Base | Change |\n` +
|
`| Metric | Base | PR | PR − Base | Change |\n` +
|
||||||
`|---|---:|---:|---:|---:|\n` +
|
`|---|---:|---:|---:|---:|\n` +
|
||||||
`${comparisonRows}\n\n` +
|
`${comparisonRows}\n\n` +
|
||||||
|
`**Interpretation:** ${interpretation}\n\n` +
|
||||||
`### Extension overhead above pi baseline\n\n` +
|
`### Extension overhead above pi baseline\n\n` +
|
||||||
`| Metric | Base overhead | PR overhead | Difference |\n` +
|
`| Metric | Base overhead | PR overhead | Difference |\n` +
|
||||||
`|---|---:|---:|---:|\n` +
|
`|---|---:|---:|---:|\n` +
|
||||||
|
|||||||
@@ -27,27 +27,27 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out benchmark implementation
|
- name: Check out benchmark implementation
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
path: benchmark
|
path: benchmark
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Check out base revision
|
- name: Check out base revision
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.base.sha }}
|
ref: ${{ github.event.pull_request.base.sha }}
|
||||||
path: base
|
path: base
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Check out PR revision
|
- name: Check out PR revision
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
path: head
|
path: head
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v7
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: npm
|
cache: npm
|
||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
base/package-lock.json
|
base/package-lock.json
|
||||||
head/package-lock.json
|
head/package-lock.json
|
||||||
|
|
||||||
- uses: oven-sh/setup-bun@v2
|
- uses: oven-sh/setup-bun@v2.2.0
|
||||||
with:
|
with:
|
||||||
bun-version: ${{ env.BUN_VERSION }}
|
bun-version: ${{ env.BUN_VERSION }}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload benchmark report
|
- name: Upload benchmark report
|
||||||
if: always() && hashFiles('memory-benchmark.md') != ''
|
if: always() && hashFiles('memory-benchmark.md') != ''
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: memory-benchmark-report
|
name: memory-benchmark-report
|
||||||
path: |
|
path: |
|
||||||
@@ -116,12 +116,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download benchmark report
|
- name: Download benchmark report
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
name: memory-benchmark-report
|
name: memory-benchmark-report
|
||||||
|
|
||||||
- name: Update sticky PR comment
|
- name: Update sticky PR comment
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v9
|
||||||
env:
|
env:
|
||||||
REPORT_PATH: memory-benchmark.md
|
REPORT_PATH: memory-benchmark.md
|
||||||
with:
|
with:
|
||||||
|
|||||||
Reference in New Issue
Block a user