perf: WHP warm-start optimizations#87
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces Windows WHP warm-start (snapshot restore) latency by adjusting the host-side restore path to preserve read-only initrd file mappings across restores, and by switching the embedded Hyperlight host dependency to a fork/branch that contains WHP warm-start optimizations (including whp-no-surrogate).
Changes:
- Update
Sandbox::restore()to userestore_preserving_file_mappings()when an initrd file mapping exists, avoiding unmap/remap on restore. - Remove stored initrd mapping base address from
Sandbox/finish_evolve()since restores no longer re-register the file mapping. - Switch
hyperlight-hostdependency todanbugs/hyperlightperf/whp-warm-startand enablewhp-no-surrogate(with corresponding lockfile updates).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| host/src/lib.rs | Uses preserving restore variant when initrd mapping exists; removes now-unneeded initrd remap bookkeeping. |
| host/Cargo.toml | Points hyperlight-host at the WHP warm-start optimization branch and enables whp-no-surrogate. |
| host/Cargo.lock | Updates locked git revision and transitive deps from the new hyperlight-host source. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # hyperlight-dev/hyperlight#1373 — Ludvig's Snapshot::to_file/from_file | ||
| # Uses PAGE_READONLY mapping (no host commit charge per VM). |
| # hyperlight-dev/hyperlight#1373 — Ludvig's Snapshot::to_file/from_file | ||
| # Uses PAGE_READONLY mapping (no host commit charge per VM). | ||
| hyperlight-host = { git = "https://github.com/hyperlight-dev/hyperlight", branch = "disk_snapshot_copy", features = ["executable_heap", "hw-interrupts"] } | ||
| hyperlight-host = { git = "https://github.com/danbugs/hyperlight", branch = "perf/whp-warm-start", features = ["executable_heap", "hw-interrupts", "whp-no-surrogate"] } |
Call restore_preserving_file_mappings when a file mapping (initrd) exists, skipping the unmap/remap cycle on every snapshot restore. Remove the now-unused file_mapping_base field. Signed-off-by: danbugs <danilochiarlone@gmail.com>
Pin to rev 3ed18580 for reproducible builds. Enables whp-no-surrogate for VirtualAlloc allocation, direct WHvMapGpaRange, and demand-zero scratch reset. Signed-off-by: danbugs <danilochiarlone@gmail.com>
62e3785 to
3537f04
Compare
There was a problem hiding this comment.
Linux Benchmarks
Details
| Benchmark suite | Current: 1e95cc0 | Previous: b15806c | Ratio |
|---|---|---|---|
hello_world (median) |
30 ms |
20 ms |
1.50 |
pandas (median) |
110 ms |
110 ms |
1 |
density (per VM) |
11 MB |
11 MB |
1 |
snapshot (disk) |
656 MiB |
656 MiB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Windows Benchmarks
Details
| Benchmark suite | Current: 1e95cc0 | Previous: b15806c | Ratio |
|---|---|---|---|
hello_world (median) |
218 ms |
347 ms |
0.63 |
pandas (median) |
213 ms |
1044 ms |
0.20 |
snapshot (disk) |
279 MiB |
663 MiB |
0.42 |
This comment was automatically generated by workflow using github-action-benchmark.
The MEM_DECOMMIT+MEM_COMMIT optimization in zero() replaced physical pages without notifying WHP, causing FC-aware dispatch (pyhl, pydriver-run) to read stale input data on Windows. Signed-off-by: danbugs <danilochiarlone@gmail.com>
Summary
Optimizes WHP snapshot-restore latency on Windows (~8x cold load, ~6x steady-state restore).
Hyperlight changes (danbugs/hyperlight@perf/whp-warm-start):
WHvSetVirtualProcessorRegisterscall for GPR + debug + special registers instead of three separate callsrestore_preserving_file_mappings— skips unmapping/remapping read-only file regions (e.g., initrd) during restore; safe because they arePAGE_READONLYat the hypervisor level and guest writes go through CoW via scratchwhp-no-surrogatefeature — for single-partition-per-process scenarios:VirtualAllocinstead ofCreateFileMappingA,WHvMapGpaRangeinstead ofWHvMapGpaRange2; scratch zeroing usesfill(0)in-place (MEM_DECOMMIT+MEM_COMMIT was removed as it desyncs the WHP GPA mapping)This repo:
restore_preserving_file_mappingswhen an initrd mapping existswhp-no-surrogateTest plan