Repository navigation
feat(disk): release a pre-committed reserve when a build hits ENOSPC (#1750 item 6) - #1774
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
…1750 item 6) A volume that fills *during* a build also starves the failure path: the log, the status file and the partial image all go to the same full volume. Following running-process #390, fbuild now commits 32 MiB of real bytes at <cache root>/emergency-reserve.bin before a build and deletes it the moment a write reports a full volume, so the error path can still be recorded and the next build has a margin. - fbuild_core::disk_reserve: EmergencyReserve (armed/released/degraded), chunked non-sparse allocation, idempotent release, ENOSPC-only spending via disk_full's existing signatures, graceful degrade when it cannot allocate. - Armed in the ESP32 pre-flight before free space is measured, so the check counts space the build can actually use. - Released from disk_full::{disk_full_error,disk_full_io_error} and disk_preflight::enospc_failure, each appending one line naming the bytes freed; re-armed by the next build. Not a budget: 32 MiB does not make a large build fit. Reclaim stays explicit (fbuild cache reclaim, #1750 item 3) and never runs mid-build (#1341).
zackees
force-pushed
the
agent/disk-reserve
branch
from
October 28, 2026 18:21
22c0791 to
3c41d6c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Pre-flight (#1767) refuses a build that starts on a full volume, and
disk_full(#1768) translatesENOSPCat a tool boundary. Neither helps when the volume fills during a build: at that instant the failure path still has to write — a build log, a daemon status file, a partially written image — onto the same full volume, and PR #1773's footprint numbers show a cold ESP32 build can consume ~4–5 GiB after the check passed.This is #1750 item 6: copy the delete-to-recover emergency reserve that the sibling
running-processdaemon ships (zackees/running-process#390).What it does
New
fbuild_core::disk_reserve:EmergencyReserve::initialize_in(dir)commits 32 MiB of real bytes at<dir>/emergency-reserve.bin.set_lenalone yields a sparse file on most filesystems and would reserve nothing, so the file is written through in 1 MiB chunks andsync_alled; a partial file from a crashed run is recreated, never trusted.release(reason)deletes it, idempotently, and reportstrueonly when this call freed something. A file already gone is tolerated.release_if_enospc(io_error)/release_if_full_message(stderr)spend it only on a real full volume, reusingdisk_full::is_enospc_io/enospc_signatureso the reserve and the error translator agree on what "full" means.Process-wide wiring, because the release must happen at every boundary that can report a full volume and none of them owns the build's disk bookkeeping:
Armed in
preflight_esp32_diskbefore measuring free space, so the pre-flight numbers are space the build can actually use.Released from
disk_full::disk_full_error/disk_full_io_erroranddisk_preflight::enospc_failure, which append one line to the message:Re-armed by the next build (
arm_inreplaces a released reserve).Deliberate non-goals: this is not a budget — 32 MiB does not make a large build fit. Real space comes from
fbuild cache reclaim, which stays explicit and never runs mid-build (#1341).fbuild doctor --check-diskis unchanged.Tests
crates/fbuild-core/src/disk_reserve_tests.rs— 8 unit tests: real-byte allocation, release idempotency, externally-deleted file, only-ENOSPC releases, tool-stderr vs errno paths, partial-file rebuild, degrade on unallocatable path, byte formatting.crates/fbuild-core/tests/disk_reserve.rs— one end-to-end test of the process-wide cycle (own binary, since the state is global): arm → unrelated failure leaves it →ENOSPCreleases it and the message says so → second failure claims nothing → next build re-arms. The two negative/positive paths share one test on purpose: two tests in that binary would race the same global.Test scratch dirs are
tempdir_in(<crate>/target/...)(ban_unrooted_tempdir), and the reserve leaf name is a bare name, not a hand-spelled path layout (ban_raw_fbuild_pathcaught exactly that in the first draft).Related: #1750 (items 1–5 landed in #1773, #1772, #1770, #1768, #1767), #1341, #1370, zackees/running-process#390.