Skip to content

Commit e9aef75

Browse files
AlfVIIclaude
andcommitted
docs(fixtures): record empirical compile-time finding (PCH wins, not migration)
The POC in commit 78f41dd measured only ~2.6% compile-time savings per migrated fixture — the "5-10x" prediction in the original fixture-registry commit message turned out to be wrong. PCH is doing the heavy lifting; the inline JSON literal was always just .rodata. Update tests/fixtures/README.md so the next contributor reading it doesn't bulk-migrate the remaining ~7 candidates expecting big compile savings — the win/cost ratio doesn't justify it. The valid reasons to migrate on a per-fixture basis (test readability, fixture reuse across test files, diff-friendliness) are now called out explicitly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 78f41dd commit e9aef75

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

tests/fixtures/README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,37 @@ loader implementation.
77

88
## Why this exists
99

10-
The MKF test binary is ~1 GB. Most of that is .rodata from huge inline
11-
JSON literals — Magnetic, Inputs, Mas — pasted as `R"({...})"` raw
12-
strings inside .cpp files. Each such literal:
10+
Inline JSON literals — Magnetic, Inputs, Mas — pasted as `R"({...})"`
11+
raw strings inside .cpp files obscure the test logic by overwhelming
12+
it with data. Moving them into NDJSON keeps the data separate from
13+
the code.
1314

14-
* is parsed at compile time (slow on heavy test TUs),
15-
* is embedded in the binary (bloats disk / debug info),
16-
* obscures the actual test logic by overwhelming it with data.
15+
## What it doesn't buy (measured)
1716

18-
Moving the big literals into NDJSON keeps them as data, not code.
17+
The original framing of this work claimed PCH + fixture migration
18+
together would shrink test compile time 5-10x. POC migration of
19+
TestPainter.cpp's 15 KB literal (commit `78f41dd8`) measured:
20+
21+
| | TestPainter.cpp.o | MKF_tests binary |
22+
|---|---:|---:|
23+
| Pre (inline literal) | 73.4 s | 25,506,048 B |
24+
| Post (fixture lookup) | 71.5 s | 25,489,448 B |
25+
| Delta | −1.9 s (~2.6 %) | −16,600 B |
26+
27+
**PCH was doing the heavy lifting** — MAS.hpp / Catch2 / json are PCH'd,
28+
so a long string literal is just .rodata, not template machinery. The
29+
binary-size win is real but modest (~150 B per JSON line moved out).
30+
31+
The remaining good reasons to migrate a fixture are:
32+
33+
* **Readability** — the test logic surfaces in a sea of inline JSON.
34+
* **Reuse across test files** — the same fixture used by multiple
35+
tests deduplicates.
36+
* **Diff-friendliness** — JSON in `.ndjson` diffs cleanly; raw
37+
strings in `.cpp` don't.
38+
39+
Migrate on a case-by-case basis when one of those is real; don't bulk
40+
migrate.
1941

2042
## On-disk layout
2143

0 commit comments

Comments
 (0)