Skip to content

Take better advantage of CoW/snapshots#437

Open
syntactically wants to merge 6 commits intomainfrom
lm/cow-wasm-work
Open

Take better advantage of CoW/snapshots#437
syntactically wants to merge 6 commits intomainfrom
lm/cow-wasm-work

Conversation

@syntactically
Copy link
Copy Markdown
Member

This should finally get the main benefits of the hyperlight core snapshot-focused CoW workflow into wasm.

@syntactically syntactically added the kind/enhancement New feature or request label Mar 30, 2026
@danbugs danbugs requested a review from Copilot March 30, 2026 21:10
Copy link
Copy Markdown

Copilot AI left a comment

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 aims to bring Hyperlight’s snapshot-driven copy-on-write (CoW) workflow into the Wasm path by deferring sandbox restores and enabling Wasmtime “memory image” support via VA remapping.

Changes:

  • Add needs_restore / restore_if_needed() to defer restoring the runtime snapshot until the next module load, reducing eager restore overhead.
  • Add WasmSandbox::load_from_snapshot() to create a loaded sandbox by restoring a snapshot taken from a LoadedWasmSandbox.
  • Implement Wasmtime memory image APIs by copying VA mappings and converting writable pages to CoW mappings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
src/hyperlight_wasm/src/sandbox/wasm_sandbox.rs Defers restore on unload via needs_restore, adds load_from_snapshot, and wires restore into some load paths.
src/hyperlight_wasm_runtime/src/platform.rs Implements Wasmtime memory image creation/mapping via page-table remaps and CoW conversion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@dblnz dblnz left a comment

Choose a reason for hiding this comment

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

Good work! 👍
I don't really have much to say to object to merging this, except maybe the Cargo.lock comment

ludfjig
ludfjig previously approved these changes Apr 2, 2026
Copy link
Copy Markdown
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

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

LGTM

@syntactically
Copy link
Copy Markdown
Member Author

@ludfjig @dblnz thanks for the reviews; can you take another look?

ludfjig
ludfjig previously approved these changes Apr 2, 2026
jsturtevant
jsturtevant previously approved these changes Apr 2, 2026
Copy link
Copy Markdown
Contributor

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

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

One comment but not blocking

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
When we are loading from a snapshot, we can get away with just a
restore and never going through a wasmtime load.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
dblnz
dblnz previously approved these changes Apr 3, 2026
…o restore

Tie together more closely the logic on when to restore the sandbox
with access to the sandbox, in a more self-contained and
easier-to-reason-about sub-module.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
@syntactically syntactically dismissed stale reviews from dblnz, jsturtevant, and ludfjig via 1c0ef3e April 3, 2026 09:38
…o restore

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
…o restore

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants