Skip to content

Cache MSRs that should be reset in default case - #1772

Merged
ludfjig merged 1 commit into
hyperlight-dev:mainfrom
ludfjig:cache_reset_msrs
Aug 26, 2026
Merged

Cache MSRs that should be reset in default case#1772
ludfjig merged 1 commit into
hyperlight-dev:mainfrom
ludfjig:cache_reset_msrs

Conversation

@ludfjig

@ludfjig ludfjig commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI lite review requested due to automatic review settings August 26, 2026 18:15
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in hyperv_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 danbugs added the kind/refactor For PRs that restructure or remove code without adding new functionality. label Aug 26, 2026
Comment thread src/hyperlight_host/src/hypervisor/virtual_machine/mod.rs
@ludfjig
ludfjig merged commit 562d25f into hyperlight-dev:main Aug 26, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor For PRs that restructure or remove code without adding new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants