Repository navigation
perf(acp): size session_start_concurrency from the host by default - #17072
Conversation
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The new cgroup ancestry walk re-implements the existing Not justified as shipped
What this change shipsInventory (9 items) — 6 justifiedIntent: let a burst of agent starts use a big host's spare capacity instead of queueing two at a time. FIX (perf).
[FIRST-PRINCIPLES-REVIEWED] 2ecb02a Description read[DESCRIPTION-READ] 66ef6508c0a1638cb047ffdbe0041be868f7b514b8c461e311adcad6f0272d01 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check per-call [DESIGN-REVIEWED] 2ecb02a Description read[DESCRIPTION-READ] a4ed272b5092c7e00189174292ef95428b0779d698e956c32c755551093e2471 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
eb2d328 to
2572080
Compare
|
|
|
|
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
2572080 to
c261d03
Compare
|
Rebased: main moved in docs/system-specs/modules/config.md, config/sections.py and slack/gateway.py since this head went green (6f70008 -> c6bfd72); CI re-running. No code change. This push also re-runs two lanes that failed on 2572080 for reasons outside the diff. The fork GPT 6.1 Review published "review incomplete" because its passes did not finish. Backend Tests (Windows) (7) failed on |
c261d03 to
c520193
Compare
|
Re-run, no code change: c520193 has the same tree as c261d03 and sits on the same base (c6bfd72). On c261d03 every review lane passed (GPT, Opus, Design, First Principles, UX, Security Scope). Seven small gate jobs in Fast Gate, Fork Workflow-Change Guard and the macOS decide step waited about 1 h 40 m without getting a runner while the repo had about 1,600 queued runs, and GitHub cancelled them at 20:33 UTC. A fork contributor cannot rerun them, so this push starts them again. |
|
|
|
c520193 to
c36e9cf
Compare
|
|
Pushed c36e9cf, rebased on main 231561d. It moves the four session_start_sizing imports to module scope (GPT span f8c2f2e6a075) and changes nothing else. The push also restarts Backend Lint & Type Check (3.12). On c520193 that job hit its 25-minute limit during mypy because black alone took 15 minutes on a slow runner. The same job passed in about 19 minutes on five other PRs at the same time, and mypy is clean locally on the changed modules. |
4466337 to
287c1ab
Compare
|
|
|
|
|
Windows shard 3 failure on 287c1ab is inherited from main, not this diff: |
|
More failures on 287c1ab, none from this diff:
|
agent.session_start_concurrency now defaults to "auto": the gateway sizes the SessionStartGate once per process as clamp(min(cpus // 4, available_GB // 3), 2, 16), with cpus the affinity count capped by the tightest cgroup v2 cpu.max quota and memory from the resource_status probe. An explicit integer still wins (clamped 1..64). session_start_sizing.py reads the host once (host_capacity) and keeps the width math separate (size_from_host) so other start limits can reuse the same reading. The gate, the subagent startup cap, the boot log and kirocrew doctor resolve "auto" through it. The config schema gives an int | str field both JSON types.
287c1ab to
2ecb02a
Compare
|
Rebased onto main cc7e798 as 2ecb02a, no behaviour change and no conflicts. This picks up #17309, which fixes the source-pin budget test that failed shard 3 on Linux and Windows. Sizing and source-pin tests (97) pass on the new base. The push also reruns the lint lane that hit its time limit and the Windows shard 2 flake. |
|
|
|
iamwhatever
left a comment
There was a problem hiding this comment.
The auto width stays safe at both ends. size_session_start_concurrency clamps to 2..16. An unknown CPU or memory reading drops out of the min instead of collapsing it to 0, and with neither known the width is the floor of 2. An explicit config value still gets the 1..64 clamp, junk falls back to auto, and the gate keeps its max(FLOOR, …), so no path gives a 0-wide gate. The cpus // 4 term already scales the width to the host. 16 is only reached at 64 or more usable cores and at least 48 GB available, so I'm fine shipping the 16 ceiling without a per-call measurement at that width. Capping usable cores by the cgroup cpu.max quota is a good touch, and so is refusing .. in the cgroup path, so docker --cpus hosts are not oversized. Moving the probe off the boot path and off the event loop is the right shape. The RFC §4.4 wording and the report-only handling of a stored 2 still need a maintainer's ruling. Neither is a correctness problem.
Problem / Motivation
Goal: On a host with spare cores and memory, a burst of agent starts no longer queues two at a time at the session-start gate.
agent.session_start_concurrency(theSessionStartGatearound ACPsession/new) defaults to 2 on every host. One kirocrew-agentsession/newtakes about 3.8 s, so at width 2 a burst of starts finishes one every 1.9 s however idle the host is. On a 128 vCPU load box with real kiro-cli, a 25-start burst had a 54 s median start at width 2 and 37 s at width 8, and at width 8 eachsession/newstill took its isolated 3.8 s.Why it matters
Anyone who fans subagents out on a workstation or a large cloud host waits tens of seconds for starts the host could run in parallel. Raising the cold-start limits alone does not help: the extra processes queue at this gate instead.
Not a goal
_COLD_START_MAX_CONCURRENT, the runtime spawn admission). A follow-up PR reuses this PR's host reading for them._bgstarts off this gate (Auto-title starts hold session-start permits that people's own chat starts are waiting for #17042).What changed (motivation → approach → change)
The width was a fixed 2, chosen for a laptop, so a big host idles behind it. The gate now defaults to
autoand the gateway sizes it once at start from what the process can use. An explicit integer in config still wins.autowidthdocker --cpus 8on a big hostThe new module
src/kiro_crew/session_start_sizing.pycomputesclamp(min(cpus // 4, available_GB // 3), 2, 16). One start uses about 3 to 4 cores while it runs and a started session tree holds about 2.6 GB.cpusis the affinity count capped by the tightest cgroup v2cpu.maxquota on the process's cgroup path, because a CFS quota sets no affinity mask. Memory comes from the same proberesource_statususes. The module reads the host once per process (host_capacity()), and every reader of the setting uses that one reading.Both readers of the setting resolve
autothrougheffective_session_start_concurrency(): the gate itself (acp/runtime_start.py, off the event loop) and the subagent startup cap (subagent.py). Nothing on the gateway boot path probes the host. After the dashboard/API socket binds,slack/gateway.pyschedules a background task that resolves the width in a worker thread, so READY never waits for the probe. The subagent manager's startup cap runs on the event loop, so it never probes or takes the host lock:cached_session_start_concurrency()sizesautofrom the cached reading once it exists and uses the floor (2) until then. The gate itself resolves its width withasyncio.to_thread. It logs the value in force with its inputs, for exampleSession start concurrency: 16 (auto: cpus=128 affinity=128 cpu.max=none available=240.5GB; ...).kirocrew doctor(doctor_checks/workload.py) runs in its own process, so it prints whatautopicks for the host at that moment and says the running value is in the boot log. The loader acceptsautoin any case or an integer clamped to 1..64; junk falls back toauto. The setting uses the stringautorather than the0 = autointeger thatagent.max_subagentsuses, because 0 already has a meaning here: the loader has always clamped this key to 1..64, so a stored 0 runs a 1-wide gate today, and reading 0 as auto would silently widen it to as much as 16.config/schema.pygives anint | strfield both JSON types so validation does not strip either spelling. Aconfig/superseded_defaults.pyrow reports a stored2from an older build. Config docs, the acp-client spec, the subagent-sizing guide (src/kiro_crew/docs/dynamic-subagent-sizing.md), the RFC §4.4 line andconfig-baseline.jsonname the new default.Relation to open work: #17017 and #17030 (bolichen97) change subagent count caps and
doctor_checks/workload.pylines next to this one (the adaptive-concurrency print), not the session-start gate. Whichever lands second has a small textual rebase in that file and inconfig/sections.py; nothing overlaps in behaviour.Backwards compatibility
Compatible: an explicit integer in config keeps its exact meaning and 1..64 clamp. Hosts with fewer than 12 usable cores, or under 9 GB available, still resolve to 2. New installs on bigger hosts get a wider gate. An existing
config.jsonholds the old default materialized as2, and that stays in force: the newsuperseded_defaultsrow is report-only, likeagent.subagent_spawn_stagger_secs, because 2 is the value an operator sets on purpose when the host or provider is the bottleneck.kirocrew doctorlists it, andkirocrew config defaults --adoptmoves an install toauto.Removes nothing: no key, value or reader goes away; the field type widens from
inttoint | str.Tests
test/test_session_start_sizing.py(new):cpu.maxparsing, the tightest-ancestor walk, the cgroup-namespace root, a v1 or..path, and 128 cores under an 8-core quota resolving to 2auto,Auto,8,"8", 0, 500, junk and bool; the schema typeauto; doctor labels anautovalue as a probe and an explicit one as configOn
origin/mainwith only the new module copied in, 9 of these fail (the default, the auto/junk/bool loader cases, the schema, the runtime resolver, the doctor line). All pass with the change.test/test_config_schema.pylearns that a scalar union flattens to its first member's type, andtest/test_config_superseded_defaults.pyplaces the new row on the report-only side.Manual verification
On the 128 vCPU dev host (no
cpu.maxquota) the gateway resolves 16. On the 128 vCPU load box, width 8 cut a 25-start burst median from 54 s to 37 s with eachsession/newat its isolated 3.8 s. The wave runs there also ran this auto formula at 16 alongside the other load fixes (burst:25 p50 18.7 to 39.5 s against 59.1 s on main), but per-callsession/newtime at 16 was not broken out. Hosts with 16 or 32 cores were not measured.Related Issues
Closes #17055
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)