Skip to content

feat(ci): make devops ci wait for a gate slot before a CPU-heavy check - #2343

Merged
dan-petty merged 6 commits into
mainfrom
feat/2336-gate-slots-code
Oct 27, 2026
Merged

dan-petty merged 6 commits into
mainfrom
feat/2336-gate-slots-code

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops ci now takes a host-wide gate slot before it starts a CPU-heavy check, so the gates of parallel agents take turns instead of all running at once. This delivers the plan that #2339 merged.

  • A run that selects test, security or typecheck, the full-suite devops ci test and devops ci coverage wait for a free slot. They print the process and worktree that hold the slots.
  • The pre-push selection, a devops ci test run narrowed by paths or by -n, a dry run and a cached verdict never wait.
  • A slot is one filelock file in ci-gate-slots/ under the data directory, which every worktree shares. The operating system frees it when the holder ends, also after SIGKILL.
  • ci.gate_slots (or DEVOPS_CLI_CI_GATE_SLOTS) sets the number of slots. The default is one for each 16 CPUs, and at least one.
  • The wait is recorded as the metric ci.gate_slot_wait_seconds and is not part of the gate time.
  • filelock becomes a direct dependency. It was already in uv.lock through tldextract.

Why 16 CPUs for each slot: on 2026-10-27, on a 16-CPU host, the 11189 tests took 247 s alone, inside the 300 s budget of the test step. Two gates side by side took 440 s each. Two gates finished both jobs only 11% sooner than two in turn. The measurement is in the design of the archived change.

Closes #2336

One gate of 11189 tests took 247 s alone and 440 s each beside a second, so 16 CPUs give 1 slot. A narrowed devops ci test run takes no slot.
…runs

A slot is a filelock file under the data directory. The operating system frees it when the holder ends or dies. Part of #2336.
The setting sets the number of gate slots. Without it, the number is one for each 16 CPUs. DEVOPS_CLI_CI_GATE_SLOTS sets it from the environment. Part of #2336.
A run that selects test, security or typecheck, the full-suite devops ci test and devops ci coverage wait for a free slot and name the holders. The pre-push selection, a narrowed test run, a dry run and a cached verdict never wait. The wait is recorded as ci.gate_slot_wait_seconds and is not part of the gate time. Part of #2336.
A real git child under the clock fixture records the stdlib's own polling sleeps, and a holder that ends right after the wait message makes the retry succeed at once. The tests now read what the gate did through the clock seam. Part of #2336.
Archives 2336-ci-gate-slots and adds the capability ci-gate-admission to the specs. Closes #2336.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence for this pull request.

  • Full gate: uv run devops ci --check --no-cache passes every check (exit 0). test took 4 m 1 s. It held the only slot, so it ran alone.
  • Two real gates, one slot, two worktrees: gate A (cold mypy cache) held the slot for 59 s. Gate B started 4 s later and printed Waiting for a CI gate slot. Allowed at one time: 1. Held by: process 620787 in …/w-2336b. It then ran its check and reported Total Elapsed: 2.64s: the wait is not part of the gate time.
  • Measurement behind the default (16 CPUs): devops ci test alone took 247 s. Two side by side took 440 s each and used 926 of the 2048 process ids of the container.
  • Red before green: the new tests failed with ModuleNotFoundError and KeyError before the code existed.
  • Load check: tests/test_ci_gate_admission.py and tests/test_ci_gate_slots.py passed six runs in a row with 16 busy loops on the 16 CPUs. This found and removed two races in the tests (the last commit).

@dan-petty
dan-petty marked this pull request as ready for review October 27, 2026 14:07
@dan-petty
dan-petty merged commit 518db63 into main Oct 27, 2026
16 checks passed
@dan-petty
dan-petty deleted the feat/2336-gate-slots-code branch October 27, 2026 14:47
dan-petty pushed a commit that referenced this pull request Oct 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.7.0](v0.6.5...v0.7.0)
(2026-10-27)


### Features

* **ci:** limit how many CPU-heavy gates run at once on one host
([#2339](#2339))
([115d1c1](115d1c1)),
closes [#2336](#2336)
* **ci:** make devops ci wait for a gate slot before a CPU-heavy check
([#2343](#2343))
([518db63](518db63)),
closes [#2336](#2336)
* **devcontainer:** onboard Kilo Code with a kilo.jsonc that exposes the
devops-cli MCP server
([#2332](#2332))
([3a6189e](3a6189e))
* **openspec:** commit the OpenSpec skills for Kilo Code
([#2334](#2334))
([9b4a824](9b4a824)),
closes [#2333](#2333)
* **repos:** add devops repos worktrees add that refuses a held issue
([#2348](#2348))
([a3b164d](a3b164d)),
closes [#2337](#2337)


### Bug Fixes

* **deps:** upgrade dnspython to fix GHSA-45c3-73f7-pv4m
([#2350](#2350))
([f50459d](f50459d))
* **k8s:** k8s apply renders the preview under --dry-run and starts no
child process
([#2328](#2328))
([16e26b0](16e26b0)),
closes [#2312](#2312)
* **k8s:** name the keyring entry when the Grafana admin password is
missing ([#2335](#2335))
([f9dcc79](f9dcc79))
* **repos:** worktrees prune removes only worktrees of merged pull
requests ([#2342](#2342))
([23d864d](23d864d)),
closes [#2341](#2341)
* **scan:** keep scan progress off stdout when the output format is json
([#2331](#2331))
([1b17048](1b17048)),
closes [#2216](#2216)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ci): limit how many CPU-heavy gates run at once on one host

1 participant