Skip to content

Document saving, loading and distributing snapshots - #2102

Open
ludfjig wants to merge 1 commit into
hyperlight-dev:mainfrom
ludfjig:docs/snapshot-workflow
Open

ludfjig wants to merge 1 commit into
hyperlight-dev:mainfrom
ludfjig:docs/snapshot-workflow

Conversation

@ludfjig

@ludfjig ludfjig commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Closes #1976

@ludfjig ludfjig added A-docs Related to documentation C-enhancement For PRs adding features, improving functionality, docs, tests, etc. labels Nov 25, 2026
@ludfjig
ludfjig requested a review from dblnz as a code owner November 25, 2026 00:51
@ludfjig ludfjig added the S-needs-review PR is ready for (re-)review label Nov 25, 2026
Copilot AI balanced review requested due to automatic review settings November 25, 2026 00:51

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.

🟡 Changes recommended

The snapshot guide omits warnings to keep loaded files unchanged while snapshots or derived sandboxes remain alive and that published snapshots may expose secrets retained in older memory layers.

2 open issues
What changed in this PR

Documents Hyperlight’s snapshot persistence and distribution workflow, with a runnable example that restores saved guest state into a new sandbox.

Changes:

  • Adds a how-to for capture, save, load, restore and registry transfer with ORAS.
  • Adds an example that verifies restored state and host callbacks.
  • Integrates the example into the existing runner and links the guide from the documentation.
File Description
src/​hyperlight_host/​examples/​snapshot/​main.rs Demonstrates saving, checked loading and restoring a snapshot.
Justfile Includes the snapshot example in run-rust-examples.
docs/​snapshot-oci-format.md Links the format reference to the workflow guide.
docs/​README.md Adds the guide to the documentation index.
docs/​how-to-save-and-load-snapshots.md Covers persistence, restore requirements, registry transfer and portability.

Review effort: Balanced

Comment on lines +37 to +39
* `checked_load` verifies blob digests. `load` skips digest verification.
Both check format and platform compatibility. Trust the publisher.
Digests do not prove authenticity.

### Push

Upload the saved layout to the registry:
@ludfjig ludfjig removed the S-needs-review PR is ready for (re-)review label Nov 25, 2026
@hyperlight-gh-bot

This comment has been minimized.

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig
ludfjig force-pushed the docs/snapshot-workflow branch from b3e0264 to 70c220d Compare November 25, 2026 18:03
@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 70c220dafe9a
Baseline commit: f739595dbf0a

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 289.90 ns (➖ 1.08x slower)
vec_bytes 78.98 ns (➖ 1.03x faster)
376.93 µs (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
65536 141.79 ns (➖ 1.00x slower)
262144 523.68 ns (➖ 1.00x slower)

sandboxes

create_initialized_and_drop
medium 13.30 ms (➖ 1.02x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
7.69 ns (➖ 1.00x slower) 7.68 ns (➖ 1.01x faster) 7.68 ns (➖ 1.04x faster)

snapshot_files

load_snapshot_unverified
small 107.86 µs (➖ 1.05x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 1.92 µs (➖ 1.08x faster) 2.04 µs (➖ 1.04x slower)
262144 6.94 µs (➖ 1.02x faster) 9.03 µs (➖ 1.27x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 6.14 µs (➖ 1.06x faster) 6.12 µs (➖ 1.08x faster)
262144 27.01 µs (➖ 1.03x faster)
8192 1.01 µs (➖ 1.01x faster) 1.03 µs (➖ 1.01x slower)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 322.16 ns (➖ 1.13x slower)
vec_bytes 98.63 ns (➖ 1.09x slower)
777.16 µs (➖ 1.05x slower)

payload_allocation

slot_pool_segmented
65536 162.23 ns (➖ 1.25x faster)
262144 598.79 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 15.13 ms (➖ 1.08x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.27 ns (➖ 1.00x faster) 8.20 ns (➖ 1.02x slower) 8.20 ns (➖ 1.02x slower)

snapshot_files

load_snapshot_unverified
small 65.59 µs (➖ 1.01x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.51 µs (➖ 1.00x slower) 2.50 µs (➖ 1.01x faster)
262144 8.79 µs (➖ 1.02x faster) 8.82 µs (➖ 1.01x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.19 µs (➖ 1.03x faster) 8.24 µs (➖ 1.03x faster)
262144 35.77 µs (➖ 1.01x faster)
8192 826.09 ns (➖ 1.00x faster) 860.89 ns (➖ 1.01x slower)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 359.46 ns (➖ 1.06x faster)
vec_bytes 100.94 ns (➖ 1.08x faster)
316.69 µs (➖ 1.00x slower)

payload_allocation

slot_pool_segmented
65536 191.45 ns (➖ 1.05x slower)
262144 670.48 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 69.16 ms (➖ 1.02x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
9.87 ns (➖ 1.00x faster) 9.88 ns (➖ 1.04x faster) 9.86 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 99.34 µs (➖ 1.08x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.43 µs (➖ 1.01x faster) 2.59 µs (➖ 1.02x faster)
262144 9.10 µs (➖ 1.03x faster) 10.76 µs (➖ 1.04x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.13 µs (➖ 1.02x faster) 7.94 µs (➖ 1.02x faster)
262144 35.21 µs (➖ 1.01x faster)
8192 1.37 µs (➖ 1.06x slower) 1.29 µs (➖ 1.00x slower)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 356.86 ns (➖ 1.02x faster)
vec_bytes 85.14 ns (➖ 1.07x faster)
710.85 µs (➖ 1.07x slower)

payload_allocation

slot_pool_segmented
65536 172.44 ns (➖ 1.51x faster)
262144 632.15 ns (➖ 1.06x faster)

sandboxes

create_initialized_and_drop
medium 83.88 ms (➖ 1.04x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.73 ns (➖ 1.00x slower) 9.10 ns (➖ 1.04x slower) 8.76 ns (➖ 1.01x slower)

snapshot_files

load_snapshot_unverified
small 54.82 µs (➖ 1.02x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.28 µs (➖ 1.01x faster) 2.26 µs (➖ 1.00x faster)
262144 7.96 µs (➖ 1.00x slower) 7.92 µs (➖ 1.00x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 7.43 µs (➖ 1.02x faster) 7.46 µs (➖ 1.01x faster)
262144 36.87 µs (➖ 1.06x faster)
8192 909.64 ns (➖ 1.01x faster) 896.62 ns (➖ 1.03x faster)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 559.56 ns (➖ 1.08x faster)
vec_bytes 163.31 ns (➖ 1.00x slower)
2.01 ms (➖ 1.02x faster)

payload_allocation

slot_pool_segmented
65536 229.55 ns (➖ 1.00x slower)
262144 797.85 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 14.02 ms (➖ 1.09x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
10.43 ns (➖ 1.00x slower) 10.21 ns (➖ 1.01x slower) 10.49 ns (➖ 1.05x slower)

snapshot_files

load_snapshot_unverified
small 702.73 µs (➖ 1.55x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.35 µs (➖ 1.01x faster) 2.36 µs (➖ 1.02x faster)
262144 9.07 µs (➖ 1.02x faster) 8.92 µs (➖ 1.06x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 9.18 µs (➖ 1.03x slower) 9.02 µs (➖ 1.03x slower)
262144 38.52 µs (➖ 1.05x faster)
8192 1.27 µs (➖ 1.07x faster) 1.30 µs (➖ 1.00x slower)
hyperv-ws2025 / intel (Windows) (❌ 1.59x)

Top regressions

  • payload_allocation/slot_pool_segmented/262144 — ❌ 1.59x slower

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 517.86 ns (➖ 1.00x faster)
vec_bytes 138.21 ns (➖ 1.03x faster)
3.36 ms (➖ 1.00x slower)

payload_allocation

slot_pool_segmented
65536 199.06 ns (➖ 1.00x slower)
262144 1.07 µs (❌ 1.59x slower)

sandboxes

create_initialized_and_drop
medium 13.83 ms (➖ 1.03x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.91 ns (➖ 1.00x slower) 8.93 ns (➖ 1.00x faster) 8.89 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 483.56 µs (➖ 1.21x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.60 µs (➖ 1.00x slower) 2.60 µs (➖ 1.01x slower)
262144 8.95 µs (➖ 1.01x slower) 8.89 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 9.48 µs (➖ 1.01x faster) 9.54 µs (➖ 1.01x faster)
262144 35.79 µs (➖ 1.24x faster)
8192 1.09 µs (➖ 1.03x faster) 1.09 µs (➖ 1.01x faster)

Reported by cargo ci bench-report --candidate run:45671195495 --config-file bench_report.toml.

* Load by tag or by the manifest digest returned by `save`.
* `checked_load` verifies blob digests. `load` skips digest verification.
Both check format and platform compatibility. Trust the publisher.
Digests do not prove authenticity.

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.

these two lines read like AI and just need alittle clean up I think

signatures. Use `SandboxBuilder::host_function` for capture and restore.
* Use the builder for runtime settings such as host functions, log level, and
mapped files. Scratch size and transport settings come from the snapshot.
* Loading needs the saved layout, not the original guest binary.

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.

After reading the rest of the bullet points here I think we want to make this whole block more readable

oras cp --to-oci-layout ghcr.io/OWNER/snapshot:v1 ./downloaded-snapshot:v1
```

Load `./downloaded-snapshot` with `OciTag::new("v1")?`.

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.

maybe you can either give an example or remove this line

@jsturtevant jsturtevant 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.

suggested some updates to wording and LGTM. Thanks for documenting this!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Related to documentation C-enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document saving, loading and distributing snapshots

3 participants