Skip to content

test(compiler): exercise repeated in-process compilation - #1409

Merged
Lorenzobattistela merged 5 commits into
bendlang:mainfrom
oxura:fix/1310-in-process-compiler-state
Oct 12, 2026
Merged

Lorenzobattistela merged 5 commits into
bendlang:mainfrom
oxura:fix/1310-in-process-compiler-state

Conversation

@oxura

@oxura oxura commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1310.

The tests never compiled more than one book in the same process, so state a compile leaves behind went unseen. #976 was one such bug: PROBES wasn't reset, so every compile kept the previous books' probes, with C still byte-identical.

gates/test.ts now has a state_run check that runs while the shards do. In one process, it loads and checks two copies of each of 4 fixtures (reg/borrow_loop, run/harness_cache_compile, run/harness_cache_purity, run/harness_cache_stats). The first copy's C and JS are the baseline. The second copy goes through c c js c snf js c +c +js c js, where snf normalizes every def and + compiles the next fixture, so it covers A -> B -> A. At every step its bytes (hashed) and the number of probes left must match the baseline. A mismatch counts as a test failure under the fixture that diverged.

The check only compiles: no clang, and it runs no programs. The shards already build and run these fixtures. It takes about 0.3 s.

  • bend2/comp.ts: PROBES is exported so the check can read its length (+1 ttok).
  • Fixture headers now describe what state_run does with them.
  • Baselines are compiled after the earlier fixtures' baselines, not each in a fresh process.

Verified: with the #976 reset removed, 4 tests fail with 40 probe mismatches. Leaks in other shared state (hot/lits/ids) aren't caught, because they don't change the probe count or the output. Gates: repo 54/54, test 1602/1602, ping 49/49.

@Lorenzobattistela Lorenzobattistela self-assigned this Oct 8, 2026

@Lorenzobattistela Lorenzobattistela left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @oxura! The check does what #1310 asks, and it catches the bug it is there for. I tested it on current main (d5fe656):

  • With the PROBES.length = 1 reset removed from file_new (the #976 bug), the test gate fails 4 tests with 40 probe-count mismatches. The bytes stay identical in that case, so the probe count is the only thing that sees it.
  • Sharing some of file_new's other maps across compilations is caught too (sites on bytes, loops on the probe count).
  • Gates on main + PR: repo 54/54, test 1594/1594, ping 48/48, perf same as main. On my machine compiler_purity took 3-6 s and the whole gates/_run.ts stayed around 20 s, the same as main.

What needs to change before merge:

  1. The 30 s cap. The gates must finish in 30 s (see gates/_run.ts), and this check has no bound on its total time. It runs 8 clang builds and 16 program runs one after another, each with its own timeout (20 s per build, 5 s per run), so the worst case is about 240 s, and the test gate waits for all of it. It is also the first part of the test gate that runs on the local machine instead of the cluster: on main every test goes to the minis, while this needs clang on whatever machine runs the gates, and its speed depends on that machine. The header of gates/test.ts still says everything runs on the cluster.
  2. Style, following the repo's style (bend.ts and the rest of gates/): 7 new lines are over 80 columns, there are 3 ifs without braces, and one line holds four compare(...) calls.
  3. Minor: only the first fixture's baseline is truly fresh; the other three are compiled after earlier fixtures in the same process. It matches a fresh process today, but "fresh baselines" in the comments overstates it.

@oxura

oxura commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Lorenzobattistela — I accept the 30-second cap and cluster-execution findings, and won’t claim the current per-process timeouts bound the entire check. I’ll revise the execution design and baseline wording, plus the bounded style fixes. @VictorTaelin: could you approve this narrowly scoped gates/ follow-up to #1310 in #1409? The test must respect the existing total gate budget and cluster ownership; I will not edit protected gate files or their allow-list/caps without your approval.

@oxura
oxura marked this pull request as draft October 8, 2026 19:36
….3 s

state_run loads each fixture twice, takes its first copy's C and JS
(hash and probes left) as the baseline and compares the second copy at
every step; the shards already run these programs. PROBES is exported
instead of a retained_probes() hook. The baselines are honest about not
coming from a fresh process. Same catch as before: without file_new's
PROBES reset, 4 tests fail with 40 mismatches.
@Lorenzobattistela
Lorenzobattistela marked this pull request as ready for review October 12, 2026 12:41
@Lorenzobattistela
Lorenzobattistela merged commit 8978cf1 into bendlang:main Oct 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test gap: Compiler-cache tests never repeat compilations in the same process

2 participants