Skip to content

defk-o08.4: each statement's reads walked once on entering it - #70

Merged
DanielLuning merged 1 commit into
mainfrom
defk-o08.4/stmt-reads-once
Oct 20, 2026
Merged

DanielLuning merged 1 commit into
mainfrom
defk-o08.4/stmt-reads-once

Conversation

@DanielLuning

Copy link
Copy Markdown
Owner

What changed

Entering a statement computed the same read set three times:

  • Copies.live_after/1, through stmt_reads/1;
  • the compiler's hoist/3, through Copies.reads/1;
  • Copies.enter_stmt/4, through reads/1 again.

reads/1 of a statement is its stmt_reads/1, because read_counts/1 already skips a match's left side.

  • Copies.block_liveness/1 returns, for each statement of a block, {live after it, its reads} from one walk. live_after/1 is now a view of it, and its tests stay.
  • The compiler's enter/3 takes {live, reads} and hands the reads to hoist/4 and to the new Copies.enter_stmt/5. enter_stmt/4 stays and computes the reads itself.
  • A property test in test/copies_test.exs checks two claims on generated blocks: reads(e) == stmt_reads(e), and block_liveness/1 agrees with live_after/1 and reads/1.
  • Docs: docs/performance.md 6.40, and ADR-0007's cost note.

Results

  • The C: mix dump_c is byte-identical for all 108 modules. The only difference is the known path-hashed defk:loop key in Defk.ReportTest.Gen.c.
  • Compiler work: measured with the DEFK_COMPILE_TIME harness (defk-o08.2: compiler time measured warm in a fresh process; the chain measured again against its budget #68), two interleaved rounds against main:
    • reductions: 125.9 M → 115.0 M (−8.6%, the same without SatEx.Kernels);
    • time: 987 → 934 ms (−5.4%).
  • The budget: against the compiler before the symbolic-bounds chain, the work is now +7.4% (−1.0% without SatEx.Kernels), down from +17.6%. That is under ADR-0007's +15% ceiling again.

Provisional: the laptop was on battery, with no quiet-machine check.

How it was checked

  • mix ci on the laptop (macOS) passed: 2304 tests, Credo found no issues, Dialyzer reported 0 errors.

  • The byte-identical mix dump_c gate, against an untouched main checkout.

  • Touches a promised surface? No. No CHANGELOG.md entry.

  • Touches test/stability/? No.

Entering a statement computed its reads three times: live_after/1
(stmt_reads/1), the compiler's hoist/3 and Copies.enter_stmt/4 (reads/1,
the same set). Copies.block_liveness/1 keeps each statement's reads beside
its live set and enter/3 hands them on; live_after/1 and enter_stmt/4 stay.
C byte-identical; the compiler's work -8.6% (reductions), time -5.4%:
+7.4% of the work before the symbolic-bounds chain, under ADR-0007's
ceiling again (docs/performance.md 6.40).
DanielLuning pushed a commit that referenced this pull request Oct 20, 2026
DanielLuning pushed a commit that referenced this pull request Oct 20, 2026
…26-10-20). Done on the branch (db0d8d0): -3.6% reductions, +3.5% of the work before step 1. PR #71, stacked on #70 (merge #70 first)."
@DanielLuning
DanielLuning merged commit dbea86b into main Oct 20, 2026
2 checks passed
@DanielLuning
DanielLuning deleted the defk-o08.4/stmt-reads-once branch October 20, 2026 11:56
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.

1 participant