Cache MSRs that should be reset in default case - #1772
Merged
Conversation
ludfjig
requested review from
andreiltd,
danbugs,
dblnz,
devigned,
jprendes,
jsturtevant,
simongdavies,
squillace and
syntactically
as code owners
August 26, 2026 18:15
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
ludfjig
force-pushed
the
cache_reset_msrs
branch
from
August 26, 2026 18:15
646a0e2 to
b732ffd
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces VM creation latency for Hyper-V style backends (MSHV on Linux, WHP on Windows) by caching the probed “MSRs to reset” index set when no additional guest MSRs are configured. This targets the common default path where SandboxConfiguration::guest_msrs(&[u8]) yields an empty list.
Changes:
- Add a
OnceLock<Vec<u32>>cache for the default (no extra guest MSRs) MSR reset index set inhyperv_msr_reset_indices. - Skip expensive MSR probing on cache hits by returning the cached index list.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
danbugs
approved these changes
Aug 26, 2026
jsturtevant
reviewed
Aug 26, 2026
jsturtevant
approved these changes
Aug 26, 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.
Cache probed MSRs when no additional msrs have been configured in
SandboxConfiguration::guest_msrs(&[u8]). Note the first sandbox will still be slow, but the rest will be fast.create_initialized: 2.251 ms → 1.443 ms, saving 0.808 ms (36%) per creation.
sandbox_from_snapshot: 1.450 ms → 0.682 ms, saving 0.768 ms (53%) per creation.