The Performance Ledger: Record, Compare, Merge
Every number in this course came out of one file: a ledger of 35 experiments, kept and rejected, with their raw results checked in beside it. Day 10 shows how the ledger works, how it was used every day, the bug it caught in itself, and how it became a small open-source tool designed with SRP, DI, IoC, MVC and pub/sub.
What one entry holds
Each experiment is one entry, written for the next engineer:
| field | example (EXP-031) |
|---|---|
| id, date | EXP-031, 2026-11-08 |
| title | Zone arrows bob from the stage frame, not a CSS keyframe animation |
| area | web |
| hypothesis | a forced style recalc at the start of every frame is caused by something invalidating style between frames |
| method | web-trace --stacks; CSS ablation; web-bench low + mid, interleaved ×2 |
| before / after | forced recalc 334 ms → 10 ms; low playground swipe 76/81 % → 36/37 % dropped |
| decision | kept (#838) |
| evidence | the test that fails on the CSS-animation version; motion parity 6 px / 1 800 ms, within 0.11 px |
| A/B | per-cell lines summarised from two benchmark files |
| results | the raw benchmark JSON, checked in under results/EXP-031/ |
The free-text fields stay free text on purpose: "neutral on this VM; a GPU fill pass on device" is more useful than a number without its caveat. The machine-readable parts are the id, the date, the verdict (the decision's first word) and the A/B.
The final ledger for this lab: 35 experiments, 28 kept, 5 rejected (Day 7), 2 measurements without a code change (a clean leak check, and a suspected nightfall cost that turned out not to exist).
How it was used, every day
- Before starting, read the ledger: has this idea been tried? (EXP-010's
will-changeresult stopped Day 8 from trying it again.) - After each A/B, record it:
record --ab before.json,after.jsonsummarises the two benchmark files into per-cell lines and copies the raw files in. - At review, the rendered
LEDGER.mdis the summary: one table row per experiment, then every entry in full. - Later, the raw results let anyone re-read the numbers behind a claim.
The bug the ledger found in itself
On the last day, two sessions worked on two branches. Both recorded "the next" experiment, so both called it EXP-034 (one was a world-open fix, the other the canvas stage), and both copied their raw files into results/EXP-034/. The text merge of the ledger conflicted; worse, the result files merged silently into one directory.
It was resolved by hand: the integration branch keeps its EXP-034, the incoming one becomes EXP-035, and only its own files move. That manual procedure became a feature, merge.
The open-source tool: perf-ledger
The in-repo script grew into a standalone, dependency-free package, perf-ledger, built so each part has one reason to change:
| principle | where it lives | what it buys |
|---|---|---|
| Single responsibility | Ledger owns ordering and id uniqueness; AbSummarizer only compares runs; MarkdownLedgerView only renders; JsonFileLedgerStore only reads and writes | a layout change touches one class |
| MVC | model domain/, views views/ (pure render(ledger)), controller controller/ (use cases) | views are tested without I/O; an HTML view needs no controller change |
| Dependency injection / IoC | the controller receives its ports; only app/container.ts creates adapters | every use case runs against in-memory fakes in tests |
| Pub/sub | the controller publishes experiment.recorded, ledger.changed; the Markdown view and the reporter subscribe | recording does not know a file is re-rendered; a Slack notifier is one events.on |
| Open/closed | a new benchmark format is a config entry; a new id scheme is an IdStrategy | extension without editing the core |
| DRY | one metric formatter, one cell escaper, one path resolver | formats cannot drift between commands |
| Objects own invariants | createExperiment validates and freezes; Ledger.add refuses duplicate ids; renumber moves result paths with the id | an invalid ledger cannot be built through the API |
npx perf-ledger init
npx perf-ledger record --title "Static layers paint from an underlay svg" --area web \
--decision kept --ab bench/before.json,bench/after.json --pr "#842"
npx perf-ledger list --verdict rejected
npx perf-ledger merge /tmp/ours.json # renumbers id collisions, moves exactly their files
record --ab reads any JSON benchmark output described in the config (where the rows are, which fields form the key, which are metrics), so supporting a new tool is configuration, not code. Its test suite includes a compatibility check: rendering the real 35-experiment ledger reproduces the original tool's table and details exactly.
Before and after: running a lab without a ledger, and with one
| without a ledger | with one |
|---|---|
| rejected ideas are forgotten and retried | five rejections, each with its numbers and reason |
| "it was faster" in a chat thread | a hypothesis, a method, before/after and evidence per change |
| numbers re-measured from scratch to answer a question | raw results checked in beside the entry |
| two branches silently collide | merge keeps the base's ids and renumbers the rest |
Design principles at work
The ledger is the course's principles applied to the process itself: measure before acting (Day 1), keep the contract and change the implementation (Days 4, 8, 9), record failures (Day 7), and separate what changes from what doesn't (the model from its views, the use cases from their side effects).
Key takeaways
- One entry per experiment, kept or rejected: hypothesis, method, before, after, decision, evidence, raw results.
- Read the ledger before starting; record into it after every A/B.
- Parallel branches need a merge that renumbers ids and moves exactly the right files.
- A small tool deserves the same design discipline as the product: MVC, injected ports, events for side effects, and tests against fakes.