Skip to content

ch: hugepages auto-detect poisons snapshots against the mmap restore fast path #157

Description

@CMGS

Problem

CH VM creation still auto-enables hugepages whenever the host has them:

// hypervisor/cloudhypervisor/args.go:52
Memory: chMemory{Size: mem, HugePages: utils.DetectHugePages(), Shared: rec.Config.SharedMemory},

Consequence chain:

  1. Every snapshot taken from such a VM is stamped hugepages=true in its config.json.
  2. validateRestoreMode rejects --restore-mode mmap for hugepages/shared snapshots (CH would otherwise silently downgrade to eager copy), so on a hugepages-configured host the CoW mmap restore path is structurally unavailable for every golden built there.
  3. All clones of those goldens are forced into eager-copy restore. Eager copy is already measured ~6x slower than mmap for a single restore (noted in restoreVM), and under a burst it turns into a guest-RAM memcpy per clone that saturates memory bandwidth — the main driver of the known burst-clone latency blowup, since extraction is already cheap (memory-range-* hardlinked, COW reflinked).

The host's hugepages configuration silently deciding guest memory policy is also a policy leak: whether a VM trades hibernate/clone-path speed for TLB benefits should be the caller's explicit choice, not an environment probe.

Precedent: #156 removed hugepages from FC entirely because FC's File restore backend cannot map hugetlbfs-backed snapshots at all. CH tolerates them (via eager copy) but pays the fast-path loss above.

Proposal

  1. Drop utils.DetectHugePages() from the CH memory config; add an explicit --hugepages create flag (same shape as the existing --shared-memory, fixed for VM lifetime). Default off.
  2. Companion change (separate PR candidate): default CH clones to mmap restore when the snapshot's memory config qualifies (plain private-anon — no hugepages, no shared); cloneAfterExtract already parses config.json, and the hardlinked memory-range files keep the backing inode alive for the mapping's lifetime. Explicit --restore-mode keeps overriding.

Validation plan

Testbed burst64 three-way comparison against one golden rebuilt without hugepages: eager copy vs --restore-mode mmap vs mmap + sqlite meta engine, recording per-step timings and p50/p99 clone latency, plus a hibernate/restore regression pass for hugepages goldens (must keep working via eager copy).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions