Repository navigation
perf(ci): spend fewer concurrency slots per pull request - #23810
Conversation
A concurrency slot is charged per job, not per core, and the account's cap is the scarce resource: standard runner minutes are free and unlimited on a public repository. Two paths spent slots that bought nothing. The unit matrix ran eight fixed shards averaging 6.5 minutes each, 3384 job-slots a day and 68% of all slot demand, while the arm pool queued 10.5 minutes at p95 — the queue was the oversharding. Five shards run the same work in ~10.5 minutes each for three fewer slots per run. Bun profile persistence escalated to all six platforms on `config/`, `resources/` and `.github/` wholesale, which took 36.5% of the last 1100 commits through the full matrix where a platform-flavoured predicate takes 19%. A pull request now qualifies one platform unless the change is platform- flavoured, and the push to main re-qualifies all six, so an unescalated miss surfaces minutes after merge rather than at the next cron. Missing changed-file evidence and an unavailable dependency graph still fail closed to all six.
|
| !file.includes('/') || | ||
| QUALIFICATION_PREFIXES.some((prefix) => file.startsWith(prefix)) || | ||
| PLATFORM_PREFIXES.some((prefix) => file.startsWith(prefix)) || | ||
| /(?:^|[/.-])(?:windows|win32|wsl|macos|darwin|linux|posix|bun)(?:[/.-]|$)/i.test(file) |
There was a problem hiding this comment.
Windows changes miss qualification A PR changing the Windows branch of
src/shared/zip-extractor-command.ts now runs Bun profile qualification only on Ubuntu: that file affects the Bun runtime build, but its path matches neither a platform prefix nor this filename check. A broken Windows build could therefore pass pre-merge qualification and reach main before the push workflow detects it.
| The initial policy is **shadow**, with every shard retained. A full run spends | ||
| `FULL_SHARD_COUNT` (five) concurrency slots: the account is charged a slot per job |
There was a problem hiding this comment.
Shard reproduction instructions are outdated This guide now says full unit runs use five shards, but
config/scripts/ci-shard-timings.md still describes eight and tells readers to reproduce a run with --shard=INDEX/8. Following that command no longer reproduces the CI assignment, which can mislead timing investigations.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe Bun profile workflow now runs on matching pushes to Priority: ➖ Normal Merge Risk: 🔵 Low · up to The rollout guidance overstates the number of shards selected runs can use. Correct it before merge or accept a bounded documentation follow-up; the checked push workflow remains eligible. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Some changes to the cross-platform Bun build can now pass a ready pull request after testing on Linux alone. The added six-platform run on main helps detect a miss, but does so after merge. No new credential authority or verified vulnerability was found. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 8 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 650191b4-6d58-46a8-93eb-e3b692f51079
📒 Files selected for processing (10)
.github/workflows/bun-profile-tests.ymlconfig/scripts/bun-profile-change-scope.mjsconfig/scripts/bun-profile-change-scope.test.mjsconfig/scripts/bun-profile-qualification.mjsconfig/scripts/bun-profile-qualification.test.mjsconfig/scripts/ci-unit-plan.mjsconfig/scripts/ci-unit-plan.test.mjsconfig/scripts/ci-unit-selection.mjsconfig/scripts/ci-unit-selection.test.mjsdocs/reference/ci-demand-rollout.md
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| const count = selected | ||
| ? Math.max(1, Math.min(8, Math.ceil(totalMs / 900_000), executionFiles.length)) | ||
| : 8 | ||
| ? Math.max(1, Math.min(FULL_SHARD_COUNT, Math.ceil(totalMs / 900_000), executionFiles.length)) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Update the selected-run shard range.
This cap limits selected runs to five shards. docs/reference/ci-demand-rollout.md still says selected runs use one to eight shards at Lines 77-78. Change that range to one to five so the rollout instructions match the planner.
There was a problem hiding this comment.
Important
This PR ships the new Bun qualification policy but leaves docs/reference/ci-demand-rollout.md's Bun-persistence section describing the policy it replaces. Please update it in this PR.
Reviewed changes
Read the full 10-file diff, traced both bunProfileQualification call sites and every consumer of the unit-shard plan, and ran the config/scripts/ contract suite against the checkout (276 files passed, 32 skipped; 108 tests across the focused shard/Bun/workflow files passed).
- Unit shards 8 → 5:
FULL_SHARD_COUNTinci-unit-selection.mjs:34replaces both hardcoded8s (ci-unit-plan.mjsfallback and the selected-mode cap). The shard list flows throughunit-plan.ymlinto theunit-tests.ymlmatrix, and nothing else pins the old count. - Bun qualification narrowed:
bun-profile-qualification.mjsdropsconfig/,resources/and.github/wholesale in favour ofconfig/patches/and.github/actions/install-node-dependencies/, addssrc/main/wsl/, and no longer takes an event — so any PR narrows toubuntu-22.04unless the change is platform-flavoured. - Push trigger for all six:
bun-profile-tests.ymladdspush: branches: [main]mirroring thepull_requestpaths, and thepersistencejob now skips drafts, guarded ongithub.event_nameso push/schedule never read the nullpull_requestproperty. - Tests and docs: workflow-shape, predicate and shard-count assertions added; the rollout doc's unit-selection section updated.
⚠️ The rollout doc still documents the qualification policy this PR replaces
docs/reference/ci-demand-rollout.md was edited for the shard change, but the Bun-persistence text a few lines above still describes behavior this PR removes: it lists configuration and resources as qualification-sensitive inputs and ends "Every non-draft synchronize event and the ready-for-review event restores full qualification." Its table also still says a ready PR runs "All six platforms when Bun inputs changed" and omits the new push: main trigger. This is the only doc describing the policy, so it currently reads as the opposite of what ships.
Technical details
# Stale Bun-persistence policy in `docs/reference/ci-demand-rollout.md`
## Affected sites
- `docs/reference/ci-demand-rollout.md:17` — "Ready PR / final checks" cell still reads "All six platforms when Bun inputs changed"; "Main reference" cell lists only the nightly at 11:30 UTC, not `push: main`.
- `docs/reference/ci-demand-rollout.md:21-29` — sensitive-input list includes `configuration` and `resources`; the closing sentence promises full qualification on every non-draft synchronize and on `ready_for_review`, both removed here.
## Required outcome
- Restate the Bun-persistence row and paragraph for the shipped policy: one platform (`ubuntu-22.04`) unless platform-flavoured; all six only for platform-marker/`config/patches/`/install-action input or on `push` to `main`; drop `configuration`/`resources` wholesale from the sensitivity list.ℹ️ Nitpicks
docs/reference/ci-runner-efficiency.md:379-383and:504-505still state the repo "has eight unit shards" and that reducing them "lacks evidence of a net gain"; this PR supersedes that conclusion, so those lines are worth annotating or updating.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| - '.github/workflows/bun-profile-tests.yml' | ||
| # The pull request qualifies one platform for an unflavoured change; this is where all six | ||
| # are re-qualified, so a platform break surfaces minutes after merge instead of next cron. | ||
| push: |
There was a problem hiding this comment.
The workflow-level concurrency group is github.event.pull_request.number || github.ref, and for schedule github.ref is the default branch — the same value this new trigger produces. With cancel-in-progress: true, a merge shortly after 11:30 UTC cancels the night's six-platform reference (and the reverse). Was that intended, or should the group include github.event_name so the daily qualification is not cancelled by a busy merge window?
Resolves the conflict with #23808 in favour of this PR's model: a Codex child's turn ends on its own turn/completed, and the one ending without it is a closed thread. #23808's child error arm and readCodexErrorWillRetry (no other consumer) are dropped; its pr-workflow-parallelism.test.mjs fix is kept.
…3745, #23783, #22971, #22565, #22846, #23724, #23721, #23693, #23810) into #23059 #23671 (group chat rows by the turn that produced them) is ported onto #23059's turn-scope model, so there is one grouping mechanism, not two: - A host that states each row's turn scope groups by that scope, as before. #23671's journal-order derivation (rows between one turn record and the next belong to it) moves from the timing selector into src/shared/native-chat-turn-grouping.ts and runs only for a host that states no scope, replacing the positional fallback there. - #23671's anchor rules live in structuredAgentTurnAnchors, which membership, settled timing and the live clock all read: a turn whose opener key nothing resolves yet takes the send still in flight ahead of its record (Codex before its echo), else its own record. - The live turn is one key again. #23671 made row liveness follow the owning turn, so the bar key and the liveness key are always the same; nativeChatTurnMembership now returns only liveTurnKey (barTurnKey, activeTurnOpenedBy and turnKeysByItemId are gone). - A turn with no user bubble draws its bar above its first row (nativeChatTurnBarRows, desktop and mobile), and a turn's diff rollup goes under its last row. - The Codex full-history restore writes each record ahead of its items; that also fixes the derived turn scope on #23059's journal. #23026 (Stop from the moment a message is sent) is ported onto #23059's command turns: the cancel paths ask the translator for a command's provider turn instead of the removed compaction tracker, and a Stop that names no turn still ends a running /compact through its child. performCancel moved to structured-agent-session-turns-cancel.ts to keep the turns module under the line limit. #22090's awaitingInput replaces showTurnStatus/showLiveTurnActivity; the waiting-behind-/compact rows are kept.

ELI5
GitHub only lets us run about 60 CI jobs at once, and we were wasting that budget. The unit tests were split into 8 pieces that each finished in 6.5 minutes — 8 parking spaces held for a very short stay — while other jobs queued 10 minutes for a space. We now split into 5 pieces. Separately, a Bun test was running on all 6 operating systems for changes that could not possibly affect any of them; it now runs on one, and all 6 run when the change actually lands on
main.What Changed
Two per-PR paths spent concurrency slots that bought nothing.
Unit shards: 8 → 5.
FULL_SHARD_COUNTinconfig/scripts/ci-unit-selection.mjsreplaces the two hardcoded8s, andci-unit-plan.mjsuses it for its fallback plan.Before: 8 shards per run, averaging 6.5 minutes each — 3,384 job-slots a day, 68% of all slot demand, while the
ubuntu-24.04-armpool queued 10.5 minutes at p95. After: 5 shards of roughly 8.8 minutes. Same total test work, three fewer slots per run.That 8.8 comes from the checked-in timing baseline rather than a guess.
balanceFilessplits 10,108 files into 5 perfectly even shards of 24.7 test-minutes (spread 0.0 min). Shards run--maxWorkers=4, and the observed 6.5-minute job against a 15.4-minute 8-shard slice implies ~2.65 minutes of fixed setup, so 24.7/4 + 2.65 ≈ 8.8.Bun profile persistence: PRs qualify one platform,
mainqualifies all six.bunProfileQualificationno longer escalates onconfig/,resources/and.github/wholesale, and no longer restricts narrowing to draft PRs. A newpush: branches: [main]trigger runs the full matrix on every merged commit, and thepersistencejob now skips drafts, matchingpr.yml.As the user experiences it: a PR touching renderer code or a vitest config gets one Linux platform instead of six platforms plus four qualification jobs; a PR touching
native/, the daemon/ssh/wsl/providers/persistence/sqlite/relay/child-process trees, a root manifest, or a platform-marked filename still gets all six before merge.Why
Standard runner minutes are free and unlimited on a public repository, so minutes are not the constraint — the plan's concurrent-job cap is, and a slot is charged per job, not per core. That inverts the usual tuning: sharding wide buys latency by spending the one resource that is actually scarce. The
ubuntu-24.04-armpool's 10.5-minute p95 queue was the oversharding, so 5 shards should be latency-positive, not merely neutral: ~8.8 min of runtime replaces 6.5 min of runtime plus up to 10.5 min of queue, while giving three slots per run back.The escalation predicate was measured, not guessed: over the last 1,100 commits on
mainit fired on 36.5%, where a platform-flavoured predicate fires on 19%. The excess was almost entirelyconfig/(158 commits) and.github/(32) — neither is platform-specific in general, and the genuinely platform-specific parts of them (config/patches/,.github/actions/install-node-dependencies/, anything with abun/windows/darwin-style marker in its name) still escalate.Alternatives considered:
mainfor up to 24 hours.push: maincosts ~17% of the PR-path volume (~75 commits/day, collapsed further by the existingcancel-in-progressgroup) and surfaces a break within minutes of merge.merge_group. Not available:mainhas no branch protection and no rulesets, so there is no merge queue to hook.ORCA_UNIT_SELECTION_MODE=selected). Measured against 12 recent shadow plans: it bails to full coverage in 10 of 12 runs, and narrows to 88.4% of files in the other 2 — roughly a 2% saving. Not worth the coverage risk; left in shadow.ubuntu-slimjobs to 4-vCPU runners. No: a slot costs the same either way, so this changes zero job counts, and everyubuntu-slimjob already averages 3–43 seconds (1.9 min worst case against a 15-min limit).Missing changed-file evidence and an unavailable dependency graph still fail closed to all six platforms.
Linked Issue
No pre-existing issue; found while auditing
ci-runner-demandoutput against the account's concurrency cap.Visual Proof
N/A— CI configuration only, no application code and no UI surface.Testing
Evidence came from the repo's own
ci-runner-demandreport (run 36522448435, 24h window, 3,965 runs, 376 sampled) plus a replay of the escalation predicate over 1,100 real commits.Local, macOS:
pnpm exec vitest run --config config/vitest.config.ts config/scripts/ci-unit-plan.test.mjs config/scripts/ci-unit-selection.test.mjs config/scripts/ci-unit-selection-review.test.mjs config/scripts/ci-shard-assignment.test.mjs config/scripts/ci-unit-sequencer.test.mjs config/scripts/bun-profile-qualification.test.mjs— 52 passedpnpm exec vitest run --config config/vitest.config.ts config/scripts/bun-profile-change-scope.test.mjs— 37 passed, including the workflow-shape assertions for the newpushtrigger and draft guardoxlint,oxfmt --check,pnpm run check:code-quality:changed— cleanNew assertions: a full plan spends
FULL_SHARD_COUNTslots;on.push.branchesis['main']with paths identical toon.pull_request.paths;persistence.ifcarries the draft guard; unflavoured inputs keep one platform and flavoured ones keep all six.Cross-platform: the narrowing decides which platforms run, and every platform-flavoured surface still escalates before merge, with
push: mainre-qualifying all six on every merged commit. SSH/relay paths (src/main/ssh/,src/relay/) are in the escalation list. Mobile unaffected.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Security: none — no permission or token-scope change. Cross-platform: covered above. Remote SSH:
src/main/ssh/andsrc/relay/still escalate to the full matrix. Mobile: unaffected. Backwards compatibility: CI-only. Performance: the point of the change — roughly 65 runner-hours/day off Bun profile persistence, ~1,270 unit job-slots/day, and ~13 runner-hours/day off the macOS pool, which is hard-capped at 5 concurrent jobs regardless of plan.Follow-up not included here, to keep this focused:
pr-test-locspends 580 slots/day on 8 seconds of work each, but it cannot fold intopr.yml's guard job — it holds a write-scoped token and deliberately never checks out PR code.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)