Skip to content

Uncompress boot entries outside the heap - #1352

Merged
yogthos merged 1 commit into
mainfrom
fix/boot-transient-structural
Oct 14, 2026
Merged

yogthos merged 1 commit into
mainfrom
fix/boot-transient-structural

Conversation

@yogthos

@yogthos yogthos commented Oct 14, 2026

Copy link
Copy Markdown
Member

The bionic footprint row kept flipping on unrelated PRs (#1333, #1335, #1336, #1340) because the boot transient sat within one 2MB chunk of the limit. Most of that transient was fragmentation, not data: each vfasl boot entry was uncompressed into a heap bytevector that the compaction before the next entry freed, and the static image placed around it kept the holes. At the end of a closed-world hello's boot on bionic, 719 segments (11.8MB) were empty but held.

The boot-load-in-place kernel patch (0003) now uncompresses a boot entry into S_getmem memory, released once the entry is loaded, and vfasl reads the image from there (S_vfasl_bytes). Runtime fasl reads keep the heap buffers. Folded into 0003 rather than a new patch since it rewrites the same hunks, which would break apply-chez-patches' reverse-check idempotency. A stock kernel (Homebrew, distro) is unchanged.

Closed-world hello from the footprint gate, bionic (tools/termux), 12 runs each, peak / live, limit is peak - live <= live/2:

old kernel  main    49,340,416 (12/12)          live ~33.07MB  headroom ~0.27MB
            #1333   49,864,704 (50,393,088 x1)  live ~33.07MB  fails
            #1336   49,864,704 (50,393,088 x1)  live ~33.07MB  fails
            #1335   49,864,704 (50,393,088 x2)  live ~33.07MB  fails
            #1340   49,864,704 (50,393,088 x1)  live ~33.07MB  fails
new kernel  main    43,945,984 (12/12)          headroom ~5.65MB
            #1333   43,945,984 (12/12)          headroom ~5.65MB
            #1336   43,945,984 (12/12)          headroom ~5.65MB
            #1335   43,945,984 (44,474,368 x1)  headroom ~5.64MB
            #1340   43,945,984 (12/12)          headroom ~5.65MB

macOS with the same patch set built locally, old 0003 vs new: 47,382,528 -> 41,975,808 for 33.07MB live (headroom 2.2 -> 7.6MB).

Startup, A/B/A, min/median: bionic closed-world hello 70.7/74.9 -> 72.7/77.4 ms (1.03x), jolt -e nil 141.1/145.9 -> 148.9/155.9 ms (1.05-1.07x); macOS hello 51.0/55.1 -> 52.5/54.9 ms, jolt -e nil 90.1/94.1 -> 91.2/96.6 ms. Keeping one buffer across entries to skip the page faults made no measurable difference to startup and cost up to 0.9MB of peak, so it is not here.

make test passes on macOS with this kernel and with Homebrew's; footprint and closedstdout pass on bionic. Linux CI caches key on the patches' hash, so the kernels rebuild.

Each vfasl boot entry was uncompressed into a heap bytevector (DSTBV) that
the compaction before the next entry freed. The static image placed around
it kept the holes, and no later buffer or image block fit them, so a boot
held several chunks of empty segments: a closed-world hello on bionic had
719 free segments (11.8MB) at the end of its boot and peaked at 49.3MB for
33MB live, at the edge of the footprint gate.

The boot-load-in-place kernel patch now uncompresses a boot entry into
memory from S_getmem, released once the entry is loaded, and vfasl reads
the image from there. The same hello peaks at 43.9MB on bionic and 42.0MB
on macOS (was 47.4MB with the same patched kernel). A stock kernel is
unaffected.
@yogthos
yogthos merged commit 9d902a7 into main Oct 14, 2026
13 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.

1 participant