Skip to content

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

Closed

Description

@cristianoc

Summary

The compiler-cache fixtures describe repeated and interleaved compilations, but the test runner executes each file once per execution mode. It does not check whether earlier compilations change later results or retain unnecessary compiler state. A historical retained-state defect provides a concrete regression case; the current probes found no incorrect compiler output.

What Bend should do

Add an in-process compiler-state check with two cases: compile one checked program repeatedly, and alternate independently loaded programs. Compare the emissions with freshly loaded program baselines, and check that retained compiler state stays bounded across repetitions.

Why

borrow_loop.bend says "The runner's reg_compiler_pure row recompiles this file in-process and byte-compares the emissions". That row lived in check/test.ts (present at 01902c52); 0dffc607 deletes that file, and d7af6bf9 adds the current borrow_loop.bend with the comment and a gates/test.ts without the row. The harness_cache_* headers (compile, purity, stats) describe repeated and interleaved operations on one cached program. The gate runs each file once per execution mode and compares its output (test_probes), which cannot observe either sequence.

A past retained-state defect

ad424afe (#976) adds PROBES.length = 1 to carb_book, the program setup that both C and JS emission run (at the baseline it is file_book, L1327, called from compile_book and js_lib). Its message says previous compilations' binder variables stayed retained and that "Bundles are byte-identical before and after". An emission comparison alone therefore does not detect this defect.

A local probe on the commit and its parent, reading PROBES.length after each C compilation, recorded:

Sequence Parent of ad424af ad424af
borrow_loop × 3 118, 235, 352 118, 118, 118
then borrow_loop, harness_cache_compile, borrow_loop 469, 550, 667 118, 82, 118

In every sequence the repeated borrow_loop emission was byte-identical to its first one. The probe observes retained state only; it shows no wrong executable.

Acceptance criteria

  • One checked program: C → C, C → JS → C, and normalization between emissions; emitted bytes and values match fresh baselines.
  • A → B → A with independently checked programs whose definitions differ; both A results match, and B matches its fresh baseline.
  • A deterministic test hook or equivalent observable asserts bounded retained compiler state across repeated compilations. The parent of ad424af fails this assertion although its emitted bytes agree.
  • The gate runs these assertions, and the fixture comments describe the sequences actually exercised.

Verification and scope

At the baseline, a local probe ran C, JS, C, normalization of each definition, JS and C on one checked program for borrow_loop and the three harness_cache_* fixtures; all emissions matched fresh baselines. No current cache-purity failure was observed.

Source baseline: 2bfc83fd6cc6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions