Skip to content

[do not merge] resident memory experiment - #143

Open
danbugs wants to merge 2 commits into
mainfrom
restore-perf
Open

danbugs wants to merge 2 commits into
mainfrom
restore-perf

Conversation

@danbugs

@danbugs danbugs commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

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
fits.then(|| (self.config.env_version(), env.as_str())),
);
drop((resolv, env));
let yielded = self.config.enter(&mut self.sandbox, "resume", (state,))?;
Comment thread CHANGELOG.md

### Changed

- Restoring a snapshot and making one guest function call takes two VM exits on x86_64, the halts that end its two entries, where it took about 12 (arm64 adds one: its kernel reseeds its CSPRNG from the host). An entry returns its `Yield` as the guest function's result. The `resume` entry carries the mounts, clock and resolver, and the environment when it fits a host call (a larger one is fetched by the first call). The kernel leaves the SYSCALL MSRs to hyperlight, which restores them. A kernel built before this, given with `from_kernel`, still works, sending its `Yield` and fetching its state by host call. A kernel built from these sources needs this `hluk` or later.
@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>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants