Skip to content

[energy] Goldilocks mmap release; shrink buffers; kill FFI allocs - #396

Merged
gregoreesmaa merged 5 commits into
mainfrom
energy/388-mmap-buffers
Oct 4, 2026
Merged

gregoreesmaa merged 5 commits into
mainfrom
energy/388-mmap-buffers

Conversation

@gregoreesmaa

Copy link
Copy Markdown
Owner

Closes #388.

What changed:

  • mmap: MAP_SHARED -> MAP_PRIVATE (read-only view); wired Goldilocks release — releaseColdPages after scan+metrics at open/reload, releaseSettledPages on the onTick settled edge + Reduce Motion snap path; new pure goldilocksScrollWindow + GoldilocksWindow with unit + wiring-audit tests; strict benchmarks untouched.
  • ViewportConfig: block_scroll_x [128]f32 inline (512 B copy per call) -> borrowed []const f32 slice over the app live table; layout/render/measure entry points take *const ViewportConfig (UnitCx borrows); all call sites + tests updated. Behavior identical (same reads, clamped the same way).
  • macos.m: CodeBlockRecord.text[8192] x64 (512 KiB + per-frame 8 KB memcpy) -> borrowed ptr+len over DrawCommand/mmap bytes; ~8-entry NSFont cache (style+quantized size keyed, ARC retained); runs >= 511 B chunked into cacheable 448 B pieces (bounded 8 links, ~4 KiB) instead of fresh CTLineCreate+CFRelease every frame.
  • macos_zatex.m: ZATEX_INPUT_CAP 65536 -> 4096 (60 KiB BSS saved incl. NFC buf); zatex_pos/zatex_gbuf 4096 -> 1024 each with over-cap run guards.

Verification (Windows host — macOS UI binary cannot build here):

  • zig build test -Doptimize=ReleaseFast: identical before/after — hot module 13/13 pass; full suite blocked by pre-existing Windows-host errors (std.c void-param, AT.FDCWD, os.windows.OpenFile, simd.zig:58), byte-identical count (17 errors) on stashed baseline vs patched tree. No new failures introduced.
  • Strict benchmarks: never loosened (no threshold touched); full benchmark run is platform-blocked here, needs macOS CI.
  • size_gate.sh + screenshot_suite.sh: macOS-only (need Cocoa link + headless renderer); NOT run here — needs CI/macOS runner. Twin-delta therefore unquoted; expected direction: core __TEXT down slightly (config-by-pointer, borrowed code text), plugin untouched.
  • Screenshots: not regenerated (platform-blocked); no rendering math changed — layout outputs flow the same values through pointers instead of copies, code-block copy path only affects clipboard bytes source.

RSS expectation: 50 MB file no longer stays ~50 MB resident after open; steady-state keeps viewport +/-1 screen. Behavior for typical docs unchanged.

gregoreesmaa added a commit that referenced this pull request Oct 3, 2026
gregoreesmaa added a commit that referenced this pull request Oct 3, 2026
gregoreesmaa added a commit that referenced this pull request Oct 4, 2026
@gregoreesmaa
gregoreesmaa force-pushed the energy/388-mmap-buffers branch from 348cbb4 to b84c183 Compare October 4, 2026 09:19
@gregoreesmaa
gregoreesmaa force-pushed the energy/388-mmap-buffers branch from 885edd2 to 0f10631 Compare October 4, 2026 15:16
@gregoreesmaa
gregoreesmaa merged commit aa673a9 into main Oct 4, 2026
5 of 6 checks 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.

[energy] Wire Goldilocks mmap release; shrink line/code/static buffers; kill FFI allocs

1 participant