The bench harness (spike S11)
bench/run.mjs is a Playwright script (the library, not the test runner).
Context
The plan sets performance gates (plan section 9). CI must fail a change that makes Lattice more than 10% slower. Shared CI runners have different speeds, and the load on a runner changes from minute to minute. An absolute time from one run is not a stable number.
Decision drivers
Not recorded in the original ADR.
Options considered
Not recorded in the original ADR.
Decision
bench/run.mjs is a Playwright script (the library, not the test runner). It opens a page
that exposes window.__latticeBench = { scenarios, run(name) }, and runs each scenario.
- Fresh page for each sample. One scenario does not change the heap or the caches of the next.
- Fixed CPU throttling. The harness sets
Emulation.setCPUThrottlingRate(4 by default) through CDP before each page load. A slow CPU makes the cost of the code larger than the noise of the runner. - Median of 5 runs. One slow run (a GC, a busy neighbor on the runner) does not change the median. Five runs keep the CI job short.
- Four metrics. Wall time of
run(name), the count of long tasks (PerformanceObserver, typelongtask), the count of animation frames, and the used JS heap after a GC (CDPRuntime.getHeapUsage). Long-task counts are more stable than times, because a task is long or it is not. - Ratios, not absolute times. With
--compare <url>, the harness also runs a second page (AG Grid Community on the same fixtures). It alternates the two pages in each run, so drift on the runner hits both sides. It writes the ratio Lattice / AG Grid for each metric. A ratio does not change when the runner is faster or slower. - The gate. With
--baseline <file>, the harness compares the ratios with the ratios in the baseline. If one side has no ratios, it compares the medians. It exits 1 when a metric is more than 10% worse. The gated metrics are wall time, long tasks and heap. Frames are not gated, because more frames can be good or bad for a scenario. - Counts of zero. The harness adds 1 to each side of a ratio. A long task where the baseline had none then gives a ratio of 2, which fails. For times and bytes, the 1 has no effect.
Each run writes bench/results/<date>.json. That folder is not in git. The baseline is a
results file that a maintainer copies to a path in git.
bench/fixtures/self-test.html has two dummy scenarios. bench/run.test.mjs runs the harness
against it in headless Chromium.
Consequences
- The app must expose
window.__latticeBench. The scenario names in the Lattice page and in the AG Grid page must be the same. - If ratios are not stable on shared runners, the fix is a self-hosted runner (plan S11).
- The harness does not record Chrome traces yet. Add them when a gate needs frame timing.
Confirmation
Not recorded in the original ADR.
Interview record
Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.
| Question | Answer | Source |
|---|---|---|
| Where does the text of this page come from? | From the Markdown file docs/adr/0008-bench-harness.md at commit 4c77ac4. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so. | Document: docs/adr/0008-bench-harness.md |
Changelog
| Date | Author | Change |
|---|---|---|
| 2026-12-01 | Joe Gaudet | Status in the Markdown file: accepted, 2026-12-01. |
| 2026-12-03 | Joe Gaudet | Commit 7ce4af2: Lattice 1.0 (#1) |
| 2026-12-04 | Joe Gaudet (agent) | Converted from docs/adr/0008-bench-harness.md to this page. The text is the text of the Markdown file. |
The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.