Repository navigation
docs(sbx): lease spec v0.2 and ADR-0048 revision after E17a - #718
Conversation
E17a (moca-experiments e17/, predictions sealed 2026-11-12) found a warm lease guest saves 89% on short commands and 40% on a stack import, but 0-8% on long compute, and nothing on a venv grep in realistic turns: per-Exec already reads through the host page cache, and every lease VM filled its 1024 MiB cgroup after one heavy command. - level 1 re-scoped to short/import-bound commands and mid-duty capacity - free-page reporting moves into v1 (replaces decision 7) - lease VM cgroups get page-cache headroom (new decision 18) - idle timeout and memory model set together; 300 s re-examined in E17b - level 2 is the latency case; size it with an E17 extension (decision 19) - §17 records the E17a findings Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
Docs-only revision of the SBX0.3 lease spec (v0.2) and ADR-0048 after E17a. It adds free-page reporting to v1, a page-cache headroom in lease cgroups, narrows level 1, points §10 at the sealed criteria, and adds §17 with the findings. The reasoning follows from the data, and the ADR decisions it replaces or narrows (3, 7, 13, 14) match the numbering on main. The code references hold on main dd0ce71: writeMemoryMax is at cgroup.go:366, and runningCommittedLocked is at budget.go:418-425. The main gap is that the new cgroup-headroom decision doesn't say how it fits the worker's reusable cgroup pool (inline).
The PR is still a draft: the pycache N = 128 rung is pending and will be added to §17. This approval covers the text at cf93f67.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (spec + ADR), cross-checked against remote-worker/internal/vmpool on main
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (all 16 checks; k8s-kind-e2e did not run on this head)
| `memory.current`, so the measured charge above follows the working set. Free page _hinting_ and a | ||
| deflate-on-OOM policy are not needed. Check before plan 3: the pinned Firecracker version's balloon | ||
| API and the guest kernel's `CONFIG_PAGE_REPORTING` (§16). | ||
| - **Page-cache headroom in the lease cgroup (v0.2).** Each VM's cgroup has `memory.max` = |
There was a problem hiding this comment.
suggestion: Per-VM cgroups aren't created per VM any more. cgroupPool (vmpool/cgroup_pool.go) keeps a free list of reused cgroups, all written once with the same memMax. Its safety argument is that a reused cgroup inherits ~1 MiB of charge. A lease cgroup with PerVMBytes + SH_LEASE_PAGECACHE_MB breaks both assumptions. (a) It needs its own free list, or a memory.max rewrite on acquire and a reset on release. (b) Host page cache charged to it stays charged to the cgroup after the VM exits, so returning it to the shared list would hand a per-Exec VM up to ~256 MiB of inherited charge under a PerVMBytes bound. Worth a sentence here, and a line in the plan that builds it.
There was a problem hiding this comment.
Agreed, and checked against cgroup_pool.go on main. Fixed in 9c23b32 (§6, "Not from the cgroup pool"): lease cgroups are never taken from or returned to the pool. The worker creates one per lease and removes it when the lease ends, so no per-Exec VM can inherit its page-cache charge. Leases are few and long-lived, so that costs one mkdir/rmdir per lease. The plan that builds lease VMs (plan 3) carries it, with a test that a per-Exec VM after a lease starts with the pool's usual ~1 MiB. The ADR's decision 18 says the same.
| ends reads from disk: in E17a a grep in such a VM took about 2 s, where a per-`Exec` VM, whose short | ||
| life left the host cache in place, took 390 ms (§17). Lease VMs get `memory.max` = | ||
| `PerVMBytes` + `SH_LEASE_PAGECACHE_MB` (default 256 MiB). The measured charge counts it when used | ||
| (`memory.current`), so it costs admission only what the host actually caches. Free-page reporting |
There was a problem hiding this comment.
suggestion: "Costs admission only what the host actually caches" understates it slightly: the lease charge is memory.current × SH_LEASE_HEADROOM (1.25, line 336). A full lease VM with full headroom is therefore charged about 1.25 × (PerVMBytes + 256 MiB) ≈ 1.6 GiB at 1 GiB guests, above a per-Exec VM's PerVMBytes. That's fine, since reclaim covers it, but state the upper bound so the §6 headroom target (SH_LEASE_RECLAIM_FREE_MB) is sized against it.
There was a problem hiding this comment.
Right, fixed in 9c23b32. §6 now states the bound, 1.25 × (PerVMBytes + SH_LEASE_PAGECACHE_MB): about 1.6 GiB at 1 GiB guests and about 680 MiB at 256 MiB guests. SH_LEASE_RECLAIM_FREE_MB's default is now 2 × PerVMBytes + max(2 GiB, 2 × (bound − SH_LEASE_START_MB)), about 4.9 GiB at 1 GiB guests and 2.6 GiB at 256 MiB guests. That also covers two busy lease VMs growing from their start estimate to the bound between samples, which reclaim cannot catch.
|
|
||
| - **Per-`Exec` already gets a warm cache from the host.** A per-`Exec` VM reads the workspace through | ||
| the host page cache, so its second grep took 390 ms against 2.2 s for the first touch of a fresh | ||
| workspace. A warm lease guest took 115 ms. The lease's cache gain is that difference, not the cold |
There was a problem hiding this comment.
nit: The back-to-back numbers differ between sections. §1.1 (line 59) says 388 → 112 ms, while §17 says 390 ms and 115 ms here (the §17 table and the ADR also use 390 ms). Pick one source (median of which run?) and use it in both places.
There was a problem hiding this comment.
Fixed in 9c23b32. One source now: the medians of the 20-call class probes in the E17 calibration (per-Exec 388 ms, warm lease 112 ms), used in §1.1, §6, §17 and the ADR.
…both N) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… one number source) - lease cgroups are created per lease and never pooled: a reused cgroup would hand a per-Exec VM the lease's leftover page-cache charge - state the lease charge bound, 1.25 x (PerVMBytes + SH_LEASE_PAGECACHE_MB) ~1.6 GiB at 1 GiB guests, and size SH_LEASE_RECLAIM_FREE_MB against it - back-to-back grep numbers from one source (class-probe medians 388/112 ms) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Firecracker v1.17.0 (P4, E15 rig and SBX0 host) supports balloon free_page_reporting (not preview; hinting is and stays out). Both guest kernels (SBX0 6.18.51, E15 6.18.44) build in VIRTIO_BALLOON, MEMORY_BALLOON, PAGE_REPORTING. Enable-before-boot means the balloon must be in the golden snapshot (per-Exec affected; two options recorded). File-backend restore makes reported pages fall back to the shared memfile. Open: whether a restored balloon keeps reporting; one restore test. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…sted) A test snapshot with a reporting-only balloon, restored by the worker with the File backend on the E15 rig: after a guest process touched 700 MiB and exited, the VM cgroup fell 734 -> 227 MiB in 5 s and to 81 MiB in 15 s; the control snapshot stayed at 734 MiB. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Per-Exec VMs carry the reporting balloon too; their latency is checked against a snapshot without it before plan 3 ships it. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…sizing Per-Exec with the balloon: true 83 -> 85 ms, python3 -c pass and a 256 MiB touch unchanged. Level 2 (a persistent interpreter): re-query 6.5 s -> 0.25 s, recompute 17.4 -> 11.2 s, ~500 MB held in a 1 GiB guest; level 1 alone 5-17%. ADR decision 19 records the sizing. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…motion A lease VM starts as a pooled standby, so its cgroup cannot be one the pool never handed out: when the VM becomes a lease VM the worker raises its memory.max, and at lease end removes the cgroup instead of returning it. Lease VMs and the balloon are plan 2's (was: plan 3). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Summary
Revises the SBX lease-mode design (SBX0.3, #698, ADR-0048) after E17a, the pre-build experiment in rossoctl/moca-experiments (
e17/, PR rossoctl/moca-experiments#21). E17a's predictions are sealed (2026-11-12).E17a ran the E15 resident patch (a stand-in for the lease, with a 300 s idle timeout) against per-
Execon a synthetic cache-heavy Python session, at N = 1 on the E15 metal host:Execgrep,sedon project files)import numpy, pandas, scipy, sklearngrep -rover the venv (realistic turns)analyze.py(CSV parse + KMeans)pytestFindings:
ExecVMs already read the workspace through the host page cache.Changes
memory.max=PerVMBytes+SH_LEASE_PAGECACHE_MB, default 256 MiB (§6);Docs only. E17a is complete: at
pycacheN = 128 the gains are short 0.91, import 0.42, grep 0.01, so criterion 2 misses at both N, as predicted. Criterion 1 holds (E15 metal, reused: 128 against 80). Report: rossoctl/moca-experimentse17/results/E17A-REPORT.md(PR #21). The plans 2–5 build decision is open.Assisted-By: Claude Code