Repository navigation
post: fstrim the buildkit sticky disk before unmount at commit - #143
magma-beef wants to merge 5 commits into
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Pruned layers keep their RBD extents allocated on the backing store until the guest discards them. Run a best-effort fstrim on /var/lib/buildkit before unmount, only when the run is still on track to commit (integrity check passed, no early deny, no SIGKILL, no failed steps) and only when the host enabled it: the VM agent returns GetStickyDiskResponse.fstrim_timeout_secs (fa live config guest_fstrim_timeout_secs), saved in action state at mount time; 0 means no trim. Any failure or timeout only logs. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 3d2979f)
…ackage predates it The bundled GetStickyDiskResponse has no fstrim_timeout_secs yet, and protobuf-es keeps fields it does not know in $unknown (the gRPC transport is binary), so decode field 8 from there when the typed field is absent. Releases built before the field existed therefore honour the host budget once the agent sends it. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 56214f0)
56214f0 to
1b5022b
Compare
|
This PR is too large for Bugbot to review. It changes 9 lines and 1,709,694 characters. Split the change into smaller pull requests to get a review. |
There was a problem hiding this comment.
✅ Devin addressed Devin Review findings on 48d373d
No findings needed changes.
|
Drop reading the unknown field 8. No hacks like that. We should get fresh proto definition (fa 6600 is merged now), and use it here. |
|
The trim result is only core.info'd; nothing lands in DockerJobLifecycle, so we can't see what a budget costs or reclaims before widening it. Please add fstrim_duration_ms, an outcome (ok / timeout / unsupported / skipped) and bytes trimmed (from fstrim -v) next to buildkitd_shutdown_duration_ms — proto + CH column in fa, then populate them in shipTeardownReport here. |
|
Should we also control how big blocks we want fstrim to communicate, if there is such setting? |
Bump @buf/blacksmith_vm-agent.bufbuild_es to the FastActions/fa main build that carries GetStickyDiskResponse.fstrim_timeout_secs (and @bufbuild/protobuf to its ^2.16.0 peer), read the typed field directly, and drop the unknown field 8 decoding. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Done in cf89a22: the unknown-field decoding is gone. |
trimFilesystem returns outcome (ok/timeout/unsupported/failed/skipped), duration and the fstrim -v byte count; the post step stores them on the lifecycle so shipTeardownReport can send them once the proto package carries the fields (fa: DockerJobLifecycle 28-30). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Agreed. Split across three PRs because the proto has to merge before this action can serialize it:
|
There is one: What happens to a small extent downstream: storageproxy passes each guest discard range 1:1 to I would not hard-code it in the action though, for the same reason the timeout isn't: make it a second agent-sent value next to the budget ( |
|
Do we need to advertise sectors at the ceph object granularity, to actually free bytes at ceph level? Or we somehow combine this on the proxy side? Additionally, it does feel like it would be useful to also have a live config knob to skip free extents smaller than configured threshold. |
No to both, as far as the code goes. The proxy does not coalesce: each guest discard range is one
So a 4 MiB alignment is not needed to free bytes; the trade-off is per-request overhead (one RADOS op per object touched) vs. bytes. ext4's FITRIM already emits one discard per contiguous free extent (bounded by the 128 MiB block group), so a disk that freed a few big layers sends few, large ranges; the pathological case is many small holes, which is exactly what the minimum-extent knob below is for. The one real gap on the proxy side is unrelated to granularity: before promotion a discard is
Agreed, added:
Suggested first value once enabled: 64 KiB (librbd's partial-discard floor), raise toward 4 MiB only if |
|
I still think that we should force the 4MiB alignment, to avoid wasting time and resources on ops that just get ignored. The knob is different - it's a trade-off decision, between deleting more data and spending less time on fstrims. And while closely related, these two settings apply at different levels, no? |
|
Agreed they are different levels: the knob is a policy choice (bytes vs. trim time) per host, the device limit is what the guest kernel is allowed to send. Two facts on what the device limit actually does before we pick the value:
So, concretely:
Both are proxy-side changes and inert until Firecracker negotiates |
|
Why not discard_sector_alignment = 4MiB ? |
|
Only because of what the kernel does with it: If the goal is "no partial-object ops, ever", the combination is: advertise 4 MiB and round each range inward to object boundaries in |
|
Done in FastActions/fa#6827 (draft pending sbauer's nod): |
GetStickyDiskResponse.fstrim_min_extent_bytes (fa #6823) is saved as action state next to the timeout budget and, when positive, becomes `fstrim -m <bytes>` so free extents below the host's threshold are not discarded. Zero or absent leaves fstrim at its default. Bumps the @buf vm-agent package to the fa main build that carries field 9. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>


In the post step, run
fstrimon the buildkit sticky disk before it is unmounted and committed, so freed blocks are discarded from the backing image.GetStickyDiskResponse.fstrim_timeout_secs. Setup reads the typed field (@buf/blacksmith_vm-agent.bufbuild_esregenerated from fa after FastActions/fa#6600) and stores it in action state;0/absent disables the trim.sync, before the usage sample andumount.timeout <budget> sudo fstrim -v; a missing binary, unsupported discard, or timeout only logs and never fails the step.ok/timeout/unsupported/failed/skipped, duration,fstrim -vbytes) is recorded on the in-memoryJobLifecycle. It is sent inDockerJobLifecycleonce the proto package is regenerated from FastActions/fa#6812 (fields 28–30); until thenshipTeardownReportomits it.Start here:
src/main.ts(post step,trimFilesystem), thensrc/setup_builder.ts(parseFstrimTimeoutSecs,fstrimFailureOutcome,parseFstrimBytes).dist/is regenerated.Checks:
npm run lint,npx tsc --noEmit -p .,npx vitest run,npm run build.Link to Devin session: https://app.devin.ai/sessions/2e17815c306b4c3cb7af4f6bce008a66
Open in Devin Desktop: https://app.devin.ai/desktop/session/2e17815c306b4c3cb7af4f6bce008a66?variant=devin
Requested by: @magma-beef
Need help on this PR? Tag
@codesmith-botwith what you need. (Staging)Need help on this PR? Tag
@codesmith-botwith what you need.