Native Playground CI Performance Guardrail
Zero-dependency N-3 regression detector for darksky/native-playground.
Metrics Schema (schema.json)
Every CI run emits perf-metrics.json containing:
schema_version: integer1.commit: full 40-character lowercase Git SHA.timestamp_utc: ISO-8601 UTC timestamp.ci_wall_ms: shared-runner wall-clock durations (lint_and_wasm,headless_linux,total_critical_path).artifacts_bytes: deterministic build output sizes (web_wasm_raw,web_wasm_gzip,headless_bin).benchmarks: deterministic engine timings ({ median, p95 }, withp95 >= median) and work counters:doc_1k_edits_msroom_sync_1k_ops_mslayout_10k_blocks_cold_mslayout_single_keystroke_mslayout_single_keystroke_blocks_relayoutedgeless_1k_pan_zoom_frame_msheadless_frame_render_ms
Individual sub-keys inside ci_wall_ms, artifacts_bytes, and benchmarks are optional (or null) when a benchmark or artifact is not yet produced by CI. Never emit synthetic 0 placeholders for unmeasured metrics: omitted or null baseline keys transition cleanly through BOOTSTRAP when first introduced instead of triggering false 0 -> positive (+inf%) regressions.
Regression Gate vs Advisory Timings
Current commit metrics are compared against the completed push run from 3 distinct prior commits (N-3) strictly older than the commit under test (--current-created-at or the commit's earliest push run on the branch).
- Library / seeding mode (default): If
N-3has no validperf-metrics.jsonartifact, the comparator walksN-3 -> N-2 -> N-1; with 0 valid prior baselines (such as the initial seeding runs of a new integration branch likedarksky/np/mobilebefore 3 runs exist) it emitsbaseline_depth: "bootstrap".--require-baselinerequires at leastN-1(baseline !== null). - Strict
N-3CI mode (--require-n3): Used on established branches (native-playground.yml). Requiresbaseline_depth === "N-3", a 40-charbaseline_commit, zero unacknowledgedDROPPEDmetrics (baseline != null && current == null), and zero unacknowledgedBOOTSTRAPmetrics (baseline == null && current != null). If all prior artifacts expire after retention, setNP_ALLOW_PERF_BOOTSTRAP=1for 3 seeding runs on the integration branch to re-establishN-3.
- Deterministic hard gate (
artifacts_bytes.*, non-_mswork counters underbenchmarks.*, and unacknowledgedDROPPED/--require-n3BOOTSTRAPmetrics):- Flagged as
REGRESSED(DROPPEDwhen missing incurrent,BOOTSTRAPwhen missing inN-3under--require-n3; setshas_hard_regression: true) whenever(current - baseline) / baseline * 100 > 10.0%(strictly greater than--threshold-pct), or whenbaseline === 0andcurrent > 0. --fail-on-regressionexits1whenhas_hard_regressionistrue.
- Flagged as
- Shared-runner wall-clock advisories (
benchmarks.*_msandci_wall_ms.*):benchmarks.*_msexceeding> 10.0%, andci_wall_ms.*exceeding both> 10.0%and> 15000ms (--ci-wall-min-delta-ms), are reported asADVISORY_SLOWDOWN(advisory: true,regressed: false, setshas_advisory_slowdown: true).- Advisory timings are surfaced in the Markdown summary and
advisory_metricsinperf-verdict.jsonfor investigation on pinned hardware without failing shared-runner CI.
Lifecycle & Regression Acknowledgements (accepted.json)
Intentional increases, newly introduced metrics, and retired metrics are recorded in perf/accepted.json (loaded by default, or via --accepted <path>):
[
{
"metric": "artifacts_bytes.web_wasm_gzip",
"accepted_value": 800000,
"reason": "Bundled new rich-text feature"
},
{
"metric": "artifacts_bytes.headless_bin",
"action": "bootstrap",
"reason": "Newly introduced metric rolling into N-3"
},
{
"metric": "benchmarks.layout_single_keystroke_blocks_relayout",
"action": "drop",
"reason": "Retired obsolete counter"
}
]
- Value ceiling (
action: "ceiling", default): When a metric triggers against the rolling baseline andcurrent <= accepted_value, the row is markedACCEPTED(regressed: false). Oncebaseline >= accepted_value, it is reported instale_acceptances. - Intentional new metric (
action: "bootstrap"): Marksbaseline == null && current != nullasACCEPTED_BOOTSTRAP(regressed: false) under--require-n3for the 3-commit rolling window; onceN-3includes the metric, it is reported instale_acceptancesfor pruning. - Intentional metric removal (
action: "drop"): Marksbaseline != null && current == nullasACCEPTED_DROP(regressed: false); onceN-3no longer contains the metric, it is reported instale_acceptancesfor pruning.
Usage
node packages/frontend/perf/compare-n3.mjs \
--fetch-github \
--repo toeverything/AFFiNE \
--branch darksky/native-playground \
--workflow native-playground.yml \
--run-id "$GITHUB_RUN_ID" \
--current artifacts/perf-metrics.json \
--json-out artifacts/perf-verdict.json \
--fail-on-regression
Self-Tests
node --test packages/frontend/perf/compare-n3.test.mjs