10

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:

fieldexample (EXP-031)
id, dateEXP-031, 2026-11-08
titleZone arrows bob from the stage frame, not a CSS keyframe animation
areaweb
hypothesisa forced style recalc at the start of every frame is caused by something invalidating style between frames
methodweb-trace --stacks; CSS ablation; web-bench low + mid, interleaved ×2
before / afterforced recalc 334 ms → 10 ms; low playground swipe 76/81 % → 36/37 % dropped
decisionkept (#838)
evidencethe test that fails on the CSS-animation version; motion parity 6 px / 1 800 ms, within 0.11 px
A/Bper-cell lines summarised from two benchmark files
resultsthe 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

  1. Before starting, read the ledger: has this idea been tried? (EXP-010's will-change result stopped Day 8 from trying it again.)
  2. After each A/B, record it: record --ab before.json,after.json summarises the two benchmark files into per-cell lines and copies the raw files in.
  3. At review, the rendered LEDGER.md is the summary: one table row per experiment, then every entry in full.
  4. 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:

principlewhere it liveswhat it buys
Single responsibilityLedger owns ordering and id uniqueness; AbSummarizer only compares runs; MarkdownLedgerView only renders; JsonFileLedgerStore only reads and writesa layout change touches one class
MVCmodel 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 / IoCthe controller receives its ports; only app/container.ts creates adaptersevery use case runs against in-memory fakes in tests
Pub/subthe controller publishes experiment.recorded, ledger.changed; the Markdown view and the reporter subscriberecording does not know a file is re-rendered; a Slack notifier is one events.on
Open/closeda new benchmark format is a config entry; a new id scheme is an IdStrategyextension without editing the core
DRYone metric formatter, one cell escaper, one path resolverformats cannot drift between commands
Objects own invariantscreateExperiment validates and freezes; Ledger.add refuses duplicate ids; renumber moves result paths with the idan 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 ledgerwith one
rejected ideas are forgotten and retriedfive rejections, each with its numbers and reason
"it was faster" in a chat threada hypothesis, a method, before/after and evidence per change
numbers re-measured from scratch to answer a questionraw results checked in beside the entry
two branches silently collidemerge 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.