vm: lazy memory restore via UFFD; stop systemd unit on restore failure#53
Merged
Conversation
|
Ready to review this PR? Stage has broken it down into 6 individual chapters for you: Chapters generated by Stage for commit c919a35 on May 13, 2026 2:52am UTC. |
dfe5d6e to
a7ffc11
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…g, bounded ioctls, LoadSnapshot timeout
… benign; drop dead UNREGISTER wrapper
pavitrabhalla
approved these changes
May 13, 2026
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.
Summary
Switches sandbox restores from Firecracker's synchronous File memory backend (CRC64-verified up front) to a userfaultfd handler that serves pages on demand. Eliminates the ~22% host CPU previously burnt on CRC64 and unblocks concurrent-create throughput.
What changed
internal/vm/uffdpackage — pure-Go UFFD handler, one per VM. Receives the userfaultfd via SCM_RIGHTS, serves UFFDIO_COPY on demand, runs a background prefetcher.access.log) into the template dir. Settle detector uses fault-rate convergence (not a fixed timeout), so each template self-tunes.access.logexists, the handler replays it in the background; on cold templates we fall back to sequential.RestoreSnapshotUffdWithOverrides— File-backend variant kept intact forinPlaceresume + theUffdEnabled=falsecircuit breaker.Safety
VMD_UFFD_ENABLED=falseflips fresh restores back to File backend, no redeploy needed. Existing UFFD-served VMs keep running on their handlers.VMD_UFFD_PREFETCH_ENABLED=falsekeeps UFFD but disables ordered prefetch and the build-time recording.record-build-*VMs use thebuild-prefix so the reconciler/persistence layer treats them as ephemeral (avoids BoltDB orphans on vmd crash).AcceptUnixwatchdog wakes on ctx cancel.LoadSnapshotbounded by 30s timeout.