uffd: record warmup faults and prefetch them on later forks#218
Draft
sjmiller609 wants to merge 1 commit intohypeship/uffd-page-serverfrom
Draft
uffd: record warmup faults and prefetch them on later forks#218sjmiller609 wants to merge 1 commit intohypeship/uffd-page-serverfrom
sjmiller609 wants to merge 1 commit intohypeship/uffd-page-serverfrom
Conversation
Adds a hot-page recorder + prefetch primitive on top of the userfaultfd page server. During a template's first warmup fork the server can record every served page (Config.RecordHotPages); the resulting HotPageList is stable-sorted, deduplicated, and saved to disk in a small binary format alongside the template. Later forks call Server.Prefetch(forkID, list) to issue UFFDIO_COPY for every recorded page against their userfaultfd before the guest unpauses, eliminating the fault round-trips on those addresses. The prefetcher is installed by the platform-specific listener once the fork's uffd has been received and registered, so callers can race Prefetch and the fault loop safely. EEXIST/EAGAIN are tolerated the same way the fault handler does to absorb first-touch races with vCPUs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5 tasks
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.
Stacked on: #216 (uffd page server) — review #213 → #214 → #216 first.
Summary
HotPage/HotPageListtypes with sort+dedup snapshot, atomicSave, andLoadHotPageList(binary varint format with aHPL1magic).Config.RecordHotPagesflag turns on per-fault recording in the page-fault loop.Server.Prefetch(forkID, list)issuesUFFDIO_COPYfor every entry in a hot-page list against the fork's userfaultfd before the guest unpauses.EEXIST/EAGAINare tolerated to absorb first-touch races with vCPUs.Why
Even with the shared mem-file + UFFD page server, a fresh fork still pays a fault round-trip on every page the guest needs to boot — that's tens of thousands of page-fault round-trips on the critical path. Recording the hot set during a template's first warmup fork and prefetching it on every later fork eliminates those round-trips entirely.
Template.HotPagesPath(reserved in PR 2) finally has a producer/consumer.Test plan
go test ./lib/uffd/...(covers HotPageList sort/dedup/save/load + bad-magic + truncation)RecordHotPages: true, save the list, fork without prefetch and time boot; fork with prefetch and time boot; confirm the second is faster🤖 Generated with Claude Code