Repository navigation
Reset layout caches before showing a new book - #1324
Conversation
|
Reproduced and verified independently on main at 565d7fd (Bun, Darwin arm64):
I did not run the full gate. |
16b78dd to
3f81276
Compare
There was a problem hiding this comment.
Thanks, the diagnosis is right: compile_book runs show_main before file_book, which is where the per-book caches are cleared, so show_main reads the previous book's NODES and LAYS. I reproduced the B → A → B crash on main. I rebased onto main (1159f0b) and pushed two commits on top of yours: one moves the fix and drops the gate check, the other renames the two cache-clearing functions. Reasons:
Where the reset goes. Clearing NODES and LAYS at the top of show_main treats the symptom:
show_maindoesn't own the compilation's lifetime.js_bookcalls it afterjs_lib, where the clear just throws away caches the same book filled.- It picks 2 of the 11 per-book caches. I instrumented
show_mainwith the clears removed and compiled all 702 runnable tests in one process. It foundLAYS,NODESandTELESalready filled.TELESis keyed by term identity, so it's harmless;NODESandLAYSare exactly the two the PR clears. That's right today, but ifshow_mainever readsFUNSorSRCSthe bug comes back.
The commits move file_book's reset into memo_gc_book() and call it first in the two compile entry points, compile_book and js_lib. js_book and io_run go through js_lib. memo_gc becomes memo_gc_def, and memo_gc_book starts by calling it, so the names say which scope each one clears. show_main keeps its place before file_book, since #1067 needs its result to build the roots. file_book keeps its name checks, and show_main is unchanged from main.
One consequence: emission now reuses what show_main cached, which is only LAYS, NODES and TELES, instead of recomputing it after file_book cleared it. So the printed descriptor and the emitted code always use the same layouts.
The gate check. gates/test.ts only orchestrates: it splits tests into shards, runs them on the cluster, and parses the output. It never loads the compiler. compiler_cache compiles on the gate host, before the cluster is acquired and inside the 30 s cap, and reports failure by throwing instead of through the PASS count. The two fixtures can't be ordinary tests either, since the sequence they describe only runs from that function. So I removed the check and both fixtures. Nothing in the current test path compiles C for several books in one process: --checkup runs a whole shard in one process but never emits C. A proper harness is #1310's job. For sizing: compiling the C for all 702 tests in one process takes about 3 s, so roughly 0.2 s per shard if it ran on the minis.
Verification:
- In one process (before the rebase onto 1159f0b): all 702 tests plus B → A → B (705 compiles), forward and reverse order. Every result matches its fresh single-process build; main throws on the final B.
- JS unchanged (also before the rebase):
js_bookandjs_lib(module mode) output is byte-identical to main's for all 702. - Bench C: all 17 benches compile to byte-identical C on 1159f0b and on this branch.
- Gates on the rebased branch:
repo50/50;comp.tsis at 63,971 of its 64,000-token cap.test1546/1546.perf123/124; the one failing cell is mandelbrot GPU at 1.16x, a flaky cell that also fails on main. Earlier runs on both this branch and main lost whole cells to builds deleted mid-run on the cluster, apparently another perf run hitting the same minis.pingwas skipped because there's no site checkout here.
tscreports no errors in the changed files.
compile_book read the last book's NODES and LAYS in show_main before file_book cleared them. The per-book reset moves into memo_reset, the first call of compile_book and js_lib, so nothing a compilation reads precedes it; show_main no longer clears caches itself. The in-process check in gates/test.ts and its two fixtures go with it: the gate driver does not compile. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The names say which scope each clears, so memo_gc_book needs no comment. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
3f81276 to
12f0848
Compare
… fresh File before show_main
What
Why
compile_book calls show_main before file_book performs its per-book cache reset. After compiling one book, a second book that reuses a datatype and constructor name with a different field layout can therefore make show_main consume the first book layout. The minimal one-field → two-field sequence throws at fs[f].ks; compiling the second book alone prints the expected value.
This is a concrete cache-purity failure exposed by the test gap in #1310; it is narrower than that issue’s full acceptance criteria.
Verification