perf(clone): hand post-resume reseed to a detached child - #175
Merged
Conversation
The synchronous vsock reseed after vm.resume waits out the guest's wakeup (tens of ms, growing with snapshot age) and dominated every clone/restore wall: 55-90ms observed, of which 35-50ms was the reseed dial+rpc. Re-exec cocoon vm reseed as a session-detached child instead; the reseed stays best-effort with the same landing time, only the CLI return advances. Resolved dirs travel as explicit flags so file- or flag-configured parents behave like env-configured ones. Spawn failure falls back to the inline path. Bare-metal A/B (CH v54, 2c/1G snapshot): seq clone 57->23ms (none) / 77->30ms (bridge); burst-16 wall 356->150ms; 16/16 agents healthy, hot-swapped NIC up with fresh MAC.
…ading verbatim copies Every CH restore decoded and re-validated cocoon.json twice (preflight on the source, AfterExtract on the merged runDir) although the file is copied verbatim between the two; DirectClone likewise parsed config.json on the source for COW classification and again on the runDir copy. PreflightRestore now returns the validated meta and the clone copy step hands its parse to cloneAfterExtractParsed, so each restore/wake and direct clone decodes each file once. FC ignores the returned meta (it reads the record instead).
…ll helpers Collection carried a store handle that nothing ever read, threaded through NewCollection/NewRecordTx/NewNamedTx/tombstone.NewTable and every caller; RecordTx shadowed its collection's ns/table. localfile Create/CreateFromDir shared an identical 13-line lease+placeholder+rollback preamble, now beginBuild; FC's lease-close loop and the CH/FC debug COW-prep block each existed twice.
Approved cut-list from the LOC audit, all call-site-verified: BaseHandler.Conf nil guards (provider wired unconditionally in root), cloneFromDir/rollbackNetwork/relay-response nil checks (all callers pass non-nil), gcTick's GC-nil clause (implied by GCInterval > 0), the producer-less SnapshotFileSkip kind, and SnapshotMeta.CPU/Memory (written by FC, read by nothing; old sidecars with the keys still parse).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every
vm clone/vm restoreends with a synchronous vsock reseed of the guest CRNG. The dial cannot complete until the resumed guest wakes up and schedules the agent's accept loop, which costs tens of milliseconds — and grows with snapshot age (fresh snapshot ~11ms, 20-minute-old ~27-36ms). On a bare-metal testbed this was 35-50ms of a 55-90ms clone wall: the single largest cost on the clone path, ahead of the CH restore itself.Warm-pool refill workloads clone long-lived golden snapshots, so they always pay the aged-snapshot path.
Change
reseedAfterResumenow re-execscocoon vm reseedas a session-detached child (Setsid) instead of dialing inline:--root-dir/--run-dir/--log-dirtravel as explicit flags, so file- or flag-configured parents behave the same as env-configured ones.Numbers (bare-metal, CH v54.0.0, 2c/1G snapshot, same host back-to-back)
--bridgeVerified after the change: 16/16 burst clones agent-healthy; hot-swapped NIC up in the guest with a fresh MAC; detached child visible re-parented to init and exiting within 1s; spawn-failure fallback exercised. Dual-GOOS lint clean, tests green on darwin and linux.