Repository navigation
perf(sandbox): size capacity by CPU, pace starts under CPU pressure, fork-free device status - #4626
Merged
Merged
Conversation
Automatic session capacity followed memory alone, so a 16 GiB host with 4 CPUs took 19 agent sessions of two CPUs each, and admission never looked at CPU. Capacity is now also at most two sessions per CPU the daemon reports (never below 8; an explicit SANDBOX_MAX_SESSIONS wins). The host-memory probe reads /proc/pressure/cpu beside /proc/meminfo where /proc describes the Docker host. While PSI "some avg10" is at or above SANDBOX_CPU_PRESSURE_PERCENT (60; 0 off), creates and warm acquisitions start one every ten seconds from the front of the first-come line and the rest answer 429 host_cpu with their place. Unknown pressure refuses nothing; a kernel without PSI is logged once.
A connected device ran `docker ps --all` (and the CPU prime sample) for every STATUS, every 15 s, on the user's machine. STATUS now comes from the spawner's own memory: registered sessions as running, creates in flight and unadopted objects as starting, plus the daemon's totals (asked at most every ten minutes) and /proc usage where /proc is the Docker host's. A daemon that does not answer leaves resources unknown instead of freezing the report. The sessions' fingerprint is checked every second and a change is reported at once, so the hub places creates on what the device runs now; the 15 s heartbeat stays, and reports never overlap.
This was referenced Oct 9, 2026
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.
What
CPU-aware capacity. With
SANDBOX_MAX_SESSIONSunset, the spawner sized capacity from memory alone, so a 16 GiB / 4 vCPU host took 19 agent sessions of two CPUs each, and admission never looked at CPU. Capacity is now at most two sessions per CPU the daemon reports (still never below 8, at most 256; an explicit value wins).CPU-pressure gate. The host-memory probe reads
/proc/pressure/cpubeside/proc/meminfowhere/procdescribes the Docker host (the same locality verdict). While PSIsome avg10is at or aboveSANDBOX_CPU_PRESSURE_PERCENT(default 60,0off), creates and warm acquisitions are let in only from the front of the existing first-come line, one every ten seconds; the rest answer 429host_cpuwith their queue place andretry-after. Nothing is reclaimed for it (an idle session uses no CPU). Unknown or unreadable pressure refuses nothing, and a kernel without PSI is logged once. The platform already treats every 429 asSpawnerBusyError.Fork-free device STATUS. A connected device ran
docker ps --all(plus a CPU prime sample) for every STATUS every 15 s on the user's machine. STATUS now comes from the spawner's registry, creates in flight and unadopted objects, plus the daemon's totals (cached ten minutes) and/procusage where local. A one-second fingerprint check reports a change at once; the 15 s heartbeat is unchanged, and reports never overlap.Docs
SANDBOX_CPU_PRESSURE_PERCENTin the env reference (EN/DE/FR),.env.exampleand the sandbox README; the capacity sizing text and the upgrade note now cover the CPU cap.docs/sessions.mdanddocs/devices.mddescribe the gate and the new STATUS source; there are two coverage rows inreference/automation/settings.md.Tests
host-memory.test.ts: CPU cap sizing, reading PSI and the CPU count, failing open once, the switch-off, rejected CPU counts.proc-stats.test.ts: parsing PSI.session-routes.test.ts: creates and acquisitions taking turns under pressure, the line keeping its order, draining once pressure eases, unknown/off/below-threshold pressure, the inventory.device.test.ts: a STATUS sent on change, nothing extra sent without a change.capacity.test.ts:hostResourcesnever runsps, and it reports unknown resources when the daemon fails.config.test.ts: parsing the new env var.