Skip to content

perf(ci): spend fewer concurrency slots per pull request - #23810

Merged
nwparker merged 1 commit into
mainfrom
nwparker/CI-offload
Sep 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/CI-offload

Conversation

@nwparker

@nwparker nwparker commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55 $\color{#cf222e}{\Huge{\mathbf{−}}}$​26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29

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_COUNT in config/scripts/ci-unit-selection.mjs replaces the two hardcoded 8s, and ci-unit-plan.mjs uses 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-arm pool 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. balanceFiles splits 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, main qualifies all six. bunProfileQualification no longer escalates on config/, resources/ and .github/ wholesale, and no longer restricts narrowing to draft PRs. A new push: branches: [main] trigger runs the full matrix on every merged commit, and the persistence job now skips drafts, matching pr.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-arm pool'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 main it fired on 36.5%, where a platform-flavoured predicate fires on 19%. The excess was almost entirely config/ (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 a bun/windows/darwin-style marker in its name) still escalate.

Alternatives considered:

  • Leave the full matrix to the existing daily cron. Cheaper, but a platform break would sit on main for up to 24 hours. push: main costs ~17% of the PR-path volume (~75 commits/day, collapsed further by the existing cancel-in-progress group) and surfaces a break within minutes of merge.
  • Gate the full matrix on merge_group. Not available: main has no branch protection and no rulesets, so there is no merge queue to hook.
  • Turn on the dormant unit-selection engine (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.
  • Upgrade the ubuntu-slim jobs to 4-vCPU runners. No: a slot costs the same either way, so this changes zero job counts, and every ubuntu-slim job 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-demand output 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-demand report (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 passed
  • pnpm 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 new push trigger and draft guard
  • oxlint, oxfmt --check, pnpm run check:code-quality:changed — clean

New assertions: a full plan spends FULL_SHARD_COUNT slots; on.push.branches is ['main'] with paths identical to on.pull_request.paths; persistence.if carries the draft guard; unflavoured inputs keep one platform and flavoured ones keep all six.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Cross-platform: the narrowing decides which platforms run, and every platform-flavoured surface still escalates before merge, with push: main re-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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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/ and src/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-loc spends 580 slots/day on 8 seconds of work each, but it cannot fold into pr.yml's guard job — it holds a write-scoped token and deliberately never checks out PR code.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Reduces CI concurrency slots by changing test shard count.

The PR should not merge until platform-dependent inputs without platform-marked filenames receive pre-merge qualification.

Findings

  1. P1 Windows changes miss qualification ▶
  2. P2 Shard reproduction instructions are outdated ▶

Summary

The PR reduces full unit runs from eight shards to five and narrows Bun profile qualification on pull requests, adding full-matrix qualification on pushes to main.

  • An unmarked, platform-dependent build input can now miss pre-merge Windows qualification.
  • The unit timing guide’s reproduction instructions still use eight shards.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  PR[Pull request] --> Scope[Classify changed files]
  Scope -->|Platform-marked| Full[Six-platform qualification]
  Scope -->|Unmarked| Linux[Ubuntu qualification]
  Linux --> Merge[Merge to main]
  Full --> Merge
  Merge --> Push[Push workflow: six-platform qualification]
Loading

Reviews (1) · Last reviewed commit: "perf(ci): spend fewer concurrency slots ..."

!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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Comment on lines +48 to +49
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The Bun profile workflow now runs on matching pushes to main and skips persistence jobs for draft pull requests. Runner qualification uses changed-file evidence and platform-specific paths, without reading event data. The full unit-test shard count is now five, and related tests and rollout figures are updated.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 36960

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 Review

Security architecture risk: 🟡 Moderate · up to 36960

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

  • Medium · security · inferred: Ready PRs changing an unflavoured, cross-platform Bun build input can receive only Linux qualification. A Windows or macOS build or profile-state regression may therefore reach main before the six-platform run detects it; the documented ready-PR guarantee still says all six run.
Security review details

Security Blast Radius

  • inferred — The affected assurance boundary is cross-platform PR qualification: an unflavoured Bun build-input change can be tested on Linux before merge but not on the Windows or macOS runners until a matching main push.

Security Findings and Attack Paths

  • inferred — A PR author can change an unflavoured build input that reaches platform-dependent native-artifact preparation and receive a Linux-only persistence verdict on a ready PR. This is a verification gap, not evidence of a working exploit or a verified vulnerability.

Trust Boundaries and Controls

  • observed — Changed repository paths influence CI coverage, not workflow token scope. Missing classification evidence selects the full matrix, and matching main pushes requalify six platforms; the workflow remains read-only with checkout credentials disabled.

Resilience and Maintainability Implications

  • inferred — The post-merge run limits detection delay for covered pushes, but path filters and the absence of evidenced failure-response controls leave its effectiveness as a recovery mechanism unproven.

Hardening Proposals

  • proposed — Align the ready-PR policy and rollout guide: either retain pre-merge multi-platform qualification for cross-platform build inputs, or explicitly treat main qualification as post-merge detection and define who responds to failures.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the primary objective: reducing CI concurrency-slot usage for pull requests.
Description check ✅ Passed The description is complete and relevant. It covers the user impact, implementation changes, rationale, alternatives, testing evidence, cross-platform considerations, visual-proof status, linked-issue…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 650191b4-6d58-46a8-93eb-e3b692f51079

📥 Commits

Reviewing files that changed from the base of the PR and between 25d9c57 and 3696068.

📒 Files selected for processing (10)
  • .github/workflows/bun-profile-tests.yml
  • config/scripts/bun-profile-change-scope.mjs
  • config/scripts/bun-profile-change-scope.test.mjs
  • config/scripts/bun-profile-qualification.mjs
  • config/scripts/bun-profile-qualification.test.mjs
  • config/scripts/ci-unit-plan.mjs
  • config/scripts/ci-unit-plan.test.mjs
  • config/scripts/ci-unit-selection.mjs
  • config/scripts/ci-unit-selection.test.mjs
  • docs/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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_COUNT in ci-unit-selection.mjs:34 replaces both hardcoded 8s (ci-unit-plan.mjs fallback and the selected-mode cap). The shard list flows through unit-plan.yml into the unit-tests.yml matrix, and nothing else pins the old count.
  • Bun qualification narrowed: bun-profile-qualification.mjs drops config/, resources/ and .github/ wholesale in favour of config/patches/ and .github/actions/install-node-dependencies/, adds src/main/wsl/, and no longer takes an event — so any PR narrows to ubuntu-22.04 unless the change is platform-flavoured.
  • Push trigger for all six: bun-profile-tests.yml adds push: branches: [main] mirroring the pull_request paths, and the persistence job now skips drafts, guarded on github.event_name so push/schedule never read the null pull_request property.
  • 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-383 and :504-505 still 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@nwparker
nwparker merged commit f8f656c into main Sep 29, 2026
40 checks passed
@nwparker
nwparker deleted the nwparker/CI-offload branch September 29, 2026 07:13
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
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.
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…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.
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.

1 participant