Skip to content

[do not merge // experiment] perf: cut the cost of a restore and a guest function call - #143

Closed
danbugs wants to merge 3 commits into
mainfrom
restore-perf
Closed

danbugs wants to merge 3 commits into
mainfrom
restore-perf

Conversation

@danbugs

@danbugs danbugs commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Makes a restore plus a guest function call about 7x faster on KVM.

restore + call on KVM stock hyperlight#1901 only this PR
dummy 880 µs 200 µs 120 µs
quickjs 1,070 µs 245 µs 157 µs
python 1,880 µs 437 µs 330 µs

Restoring a snapshot and making one guest function call took about 12
VM exits; on a nested hypervisor each costs several microseconds. Each
entry now costs one, the halt that ends it:

- An entry returns its Yield as the guest function's result (a Vec<u8>:
  next wakeup, flags, status, then the call's result) rather than send it
  with a host call. The first entry after a restore reports a ready
  driver and a call in flight on that Yield, not with DriverReady and
  CallStarted host calls.
- The resume entry carries the mounts, the clock, the resolver and, when
  it fits a host call's payload, the environment, which the kernel
  fetched with GetResumeState and, on the first call, GetEnvVars.
- The kernel leaves the SYSCALL MSRs to hyperlight, which restores the
  ones the host declares.

A kernel from before this (given with from_kernel) still works: its
entries return nothing, it sends its Yield by host call, and
GetResumeState stays for it. A result too short to be a Yield is an
error of its own, MalformedYield.

Bump the kernel to plat-hyperlight-v2 bd441efa -> fd70ccb9 (the three
changes above, and bounds on the FlatBuffer offsets the guest reads),
rebuild both kernels and the native test fixture, and bump
SNAPSHOT_CONTRACT: every guest function now returns a Vec<u8>.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 23:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The embedded kernels lack the new ABI, while legacy resume entries are called with an incompatible argument.

2 open findings
What changed in this PR

Optimizes restore and guest-call VM exits while testing a resident-scratch Hyperlight fork.

Changes:

  • Returns Yield data through entry results and carries resume state directly.
  • Adds restore/environment tests and updates protocol documentation.
  • Pins experimental Hyperlight dependencies and bumps snapshot compatibility.
File Description
src/​lib.rs Implements the new entry and resume protocol.
tests/​python.rs Tests environment restoration paths.
docs/​profiling.md Updates profiling examples.
docs/​fs.md Documents restored mount handling.
docs/​execution.md Documents entry results and resume state.
docs/​driver.md Updates driver restore behavior.
docs/​clock.md Updates restored clock behavior.
CHANGELOG.md Records the protocol optimization.
Cargo.toml Patches Hyperlight to an experimental fork.
Cargo.lock Locks the fork revision.
build.rs Bumps the snapshot contract.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread src/lib.rs
Comment thread CHANGELOG.md
@danbugs
danbugs force-pushed the restore-perf branch 2 times, most recently from f62ccee to 82c468b Compare October 9, 2026 00:27
Patch hyperlight-host and hyperlight-common to danbugs/hyperlight
c854bb43 (0.17.0 plus the scratch reset of hyperlight-dev/hyperlight#1901),
to measure it in CI.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs danbugs changed the title [do not merge] resident memory experiment perf: cut the cost of a restore and a guest function call Oct 13, 2026
…ight

[do not merge] build against the resident scratch reset hyperlight

Patch hyperlight-host and hyperlight-common to danbugs/hyperlight
ff80dda2 (0.17.0 plus the scratch reset of hyperlight-dev/hyperlight#1901),
to measure it in CI.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs danbugs changed the title perf: cut the cost of a restore and a guest function call [do not merge // experiment] perf: cut the cost of a restore and a guest function call Oct 15, 2026
@danbugs

danbugs commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour #162

@danbugs danbugs closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants