ludic/examples/lang/alloc_fence_unbounded.ludic
Orkuncakilkaya 0f04b63516 fence: declared but unbounded, and a rewarm that keeps the warm-up's deadline
Two blind spots from the windowed walk, where the heap grew about 1 MB a minute and the census read
`frames 0 bad 0 kept 0`:

- @alloc_ok memory was never held to its reason. Every R3D_ALLOC_DWIN judged frames (600) each site's
  declared bytes are set against their high-water mark: a new high adds to a streak, a flat window
  takes one off, a fall ends it. R3D_ALLOC_DRISE (6) is "declared but unbounded", said once per site
  with its line; fail mode exits 86. The census adds `unbounded N` and a `dsite` row per declared
  site by its growth since judging began. A list pushed forever grows by doubling, rising too seldom
  to make a streak; a record or text made every time (a re-mount's defaults) is what it catches.
- Mem.play() (every screen opened) restarted the warm-up, so memory kept every frame was never flat,
  the cap never came, and nothing was ever judged. A rewarm now keeps the first deadline, and past it
  has R3D_ALLOC_REWARM frames (120) of grace.

Goldens: alloc_fence_unbounded (a record a frame under @alloc_ok: exit 86, named, census unbounded 1);
alloc_fence_rewarm (kept every frame, Mem.play() every 360: judged and failed at frame 3000 - the
toolchain before this runs all 6000 frames and exits 0). alloc_fence_leak, _declared, _auto,
alloc_ok_private and the four arena goldens unchanged; the game's frame ratchets 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:36:08 +03:00

21 lines
799 B
Text

# alloc_fence_unbounded.ludic - 25.1: @alloc_ok says a frame's memory is bounded by its reason, and the
# fence holds it to that: a declared site whose bytes keep rising window after window is "declared
# but unbounded", and the failing fence fails the run (exit 86) - here a record a frame, as a screen
# whose defaults run again on every re-mount makes. Run with small windows:
# R3D_ALLOC_DWIN=20 R3D_ALLOC_DRISE=4
program AllocFenceUnbounded {
property Row { v: int = 0 }
property Memo { rows: []Row = new []Row }
@alloc_ok("a memo miss")
function remember(m: Memo, f: int) -> void {
push(m.rows, new Row { v: f })
}
entry {
let m = new Memo
for f in 0 .. 2000 {
remember(m, f)
Mem.frame()
}
print(`bad {Mem.bad_frames()} rows {len(m.rows)}`)
}
}