Repository navigation
Write initial snapshot memory in place - #1927
Merged
Merged
Conversation
ludfjig
requested review from
andreiltd,
danbugs,
dblnz,
devigned,
jprendes,
jsturtevant,
simongdavies,
squillace and
syntactically
as code owners
October 12, 2026 20:01
This comment has been minimized.
This comment has been minimized.
ludfjig
force-pushed
the
ll/2-lazy-sandbox-memory
branch
from
October 13, 2026 18:56
96fab64 to
ab775e0
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Lazy no-reserve allocations need aggregate admission or commitment accounting to prevent deferred host-wide OOM.
1 open finding
What changed in this PR
Optimizes sandbox creation by constructing initial snapshot memory directly in shared memory and relying on lazy page population.
Changes:
- Writes guest initialization data in place.
- Freezes shared memory without copying.
- Documents the performance improvement.
| File | Description |
|---|---|
src/hyperlight_host/src/sandbox/snapshot/mod.rs |
Builds snapshots directly in shared memory. |
src/hyperlight_host/src/mem/shared_mem.rs |
Restricts the copying helper to tests and HVF. |
CHANGELOG.md |
Documents lazy memory population. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ludfjig
force-pushed
the
ll/2-lazy-sandbox-memory
branch
from
October 13, 2026 21:01
ab775e0 to
107a858
Compare
This comment has been minimized.
This comment has been minimized.
ludfjig
force-pushed
the
ll/2-lazy-sandbox-memory
branch
from
October 13, 2026 23:00
107a858 to
aa55340
Compare
This comment has been minimized.
This comment has been minimized.
andreiltd
previously approved these changes
Oct 14, 2026
ludfjig
force-pushed
the
ll/2-lazy-sandbox-memory
branch
from
October 15, 2026 22:00
aa55340 to
421a453
Compare
This comment has been minimized.
This comment has been minimized.
ludfjig
force-pushed
the
ll/2-lazy-sandbox-memory
branch
from
October 21, 2026 19:27
421a453 to
5631afe
Compare
This comment has been minimized.
This comment has been minimized.
ludfjig
force-pushed
the
ll/2-lazy-sandbox-memory
branch
from
October 26, 2026 18:44
5631afe to
5c04ce3
Compare
Snapshot::from_env writes the guest code, PEB and init data straight into shared memory and freezes it. The host populates the remaining pages on first guest touch, so sandbox creation cost stays independent of heap size. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
ludfjig
force-pushed
the
ll/2-lazy-sandbox-memory
branch
from
October 30, 2026 19:14
5c04ce3 to
b50c34e
Compare
Benchmark ResultsMeasured commit: kvm / amd (Linux) (🌟 6.06x)Top improvements
Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
kvm / intel (Linux) (🌟 5.41x)Top improvements
Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / amd (Windows) (🌟 7.79x)Top improvements
Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / intel (Windows) (🌟 7.87x)Top improvements
Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
Reported by |
Contributor
|
it is interesting that benchmarks are reporting increases for everything but mshv 🤔 |
jsturtevant
approved these changes
Oct 30, 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.

New sandboxes skip copying their initial memory.
Snapshot::from_envwrites the guest code, PEB, init data and page tables in place, and the host populates the rest, mostly the heap, on first guest touch.Benchmarks
Compared to
main. MSHV runs Linux 6.6.137.mshv2-5 and 6.6.100.mshv1-2. KVM runs Linux 6.17.sandboxes/create_initialized/smallsandboxes/create_initialized/mediumsandboxes/create_initialized/largesnapshot_files/cold_start_via_evolve/large6.6.100 gains less because it pins guest memory, while 6.6.137 maps it as movable regions. On 6.6.137, a fresh sandbox's first call that writes 32 MiB of heap is 4% slower. Other benchmarks are unchanged.