Skip to content

fix(ci): cap shard test concurrency at 50% so browser suites don't starve the runner - #421

Closed
omridevk wants to merge 2 commits into
mainfrom
fix/389-ci-shard-concurrency-cap
Closed

omridevk wants to merge 2 commits into
mainfrom
fix/389-ci-shard-concurrency-cap

Conversation

@omridevk

@omridevk omridevk commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Every main CI run since 99bbfa8f (Aug 10) has failed shard-4 with [vitest] Browser connection was closed, killing the @conciv/app browser suite. That's 9/9 reds on main.

  • The identical package set runs 44/44 green on a 4-CPU docker rig, ruling out a test-content regression.
  • CI runs TURBO_CONCURRENCY=100% uncapped on GitHub's 4-vCPU runners, while multiple Chromium fleets + vite dev hosts run concurrently across the shard's packages — the runner saturates.
  • Vitest's browser mode has no session reconnect (upstream vitest-dev/vitest#10791), so once the websocket to the browser starves under CPU pressure, the run just dies instead of retrying.
  • The repo already caps turbo at 50% locally for exactly this saturation reason (turbo.json); CI deliberately re-uncaps to 100% per workflow for speed on dedicated runners — this shard job is the one case where dedicated isn't enough.

Change

Scoped the fix to only the build + test (shard-N) matrix job in .github/workflows/ci.yml: added a job-level env: TURBO_CONCURRENCY: '50%', which overrides the workflow-level 100% default for just that job's steps. Every other job (plan, repo-checks, storybook, plan-e2e, e2e, e2e-summary, zizmor) is untouched and keeps running at 100%.

Test plan

  • Land this PR and watch 5+ consecutive main CI runs for shard-4 (and the rest of the matrix) going green, confirming the browser-connection-closed failure stops recurring.
  • If it recurs, the next lever is trimming which packages share a shard with @conciv/app, or a runner-size bump — not covered by this change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved build stability by limiting concurrency on 4-vCPU runners.
    • Added automatic diagnostics for each build shard, including system resource usage and browser process information.
  • Documentation

    • Clarified concurrency behavior across CI workflows and build jobs.

…arve the runner (#389)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CI build job now limits Turbo concurrency to 50%. Each shard records runner resource data and uploads kernel logs and sampler output as an always-run diagnostic artifact.

Changes

CI resource control

Layer / File(s) Summary
Build concurrency control
.github/workflows/ci.yml
The workflow documents resource contention between build processes and browser sessions. The build job sets TURBO_CONCURRENCY to 50%.
Per-shard runner diagnostics
.github/workflows/ci.yml
Each shard samples memory, swap, load, and Chromium process counts every two seconds. An always-run step collects kernel logs and sampler output and uploads the runner-diag artifact.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main CI change: limiting shard test concurrency to 50% to prevent browser suite runner starvation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/389-ci-shard-concurrency-cap

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

…389)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

155-161: 🚀 Performance & Scalability | 🔵 Trivial

Add direct cgroup CPU telemetry for throttling diagnosis.

The workflow captures dmesg and resource samples, but not the active cgroup’s cpu.stat. When available, capture nr_throttled and throttled_usec, or narrow the comment to the evidence collected.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 155 - 161, Extend the “Capture runner
diagnostics” step to read the active cgroup’s cpu.stat when available and
persist nr_throttled and throttled_usec alongside the existing dmesg output,
while tolerating unavailable cgroup paths or read failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 147: Update the sampler command around the Chromium process count to
capture pgrep’s output while preventing its nonzero status from triggering the
fallback, then emit ${chrom_count:-0} so no-match cases produce exactly one zero
without a newline.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 155-161: Extend the “Capture runner diagnostics” step to read the
active cgroup’s cpu.stat when available and persist nr_throttled and
throttled_usec alongside the existing dmesg output, while tolerating unavailable
cgroup paths or read failures.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f215bd5c-fe21-448f-b543-47e6e47f534f

📥 Commits

Reviewing files that changed from the base of the PR and between b412200 and f133d37.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Comment thread .github/workflows/ci.yml
nohup bash -c '
while true
do
echo "$(date +%s) mem=$(free -m | awk "/^Mem:/{print \$3\"/\"\$2}") swap=$(free -m | awk "/^Swap:/{print \$3}") load=$(cut -d" " -f1-3 /proc/loadavg) chrom=$(pgrep -c chrom 2>/dev/null || echo 0)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

sample="$(pgrep -c '^__coderabbit_no_such_process__$' 2>/dev/null || echo 0)"
if [[ "$sample" == $'0\n0' ]]; then
  echo "The fallback emits duplicate zero lines."
  exit 1
fi

Repository: conciv-dev/conciv

Length of output: 155


🏁 Script executed:

#!/usr/bin/env bash
set -u

pattern='^__coderabbit_no_such_process_9f3c7b__$'

printf '%s\n' '--- direct pgrep ---'
set +e
direct="$(pgrep -c "$pattern" 2>/tmp/pgrep.err)"
status=$?
set -e
printf 'status=%s\n' "$status"
printf 'stdout=%q\n' "$direct"
printf 'stderr=%q\n' "$(cat /tmp/pgrep.err)"

printf '%s\n' '--- command substitution with fallback ---'
set +e
sample="$(pgrep -c "$pattern" 2>/dev/null || echo 0)"
status=$?
set -e
printf 'status=%s\n' "$status"
printf 'quoted=%q\n' "$sample"
printf 'lines=%s\n' "$(printf '%s\n' "$sample" | wc -l)"

printf '%s\n' '--- workflow expression shape ---'
set +e
line="$(echo "ts=1 chrom=$(pgrep -c "$pattern" 2>/dev/null || echo 0)")"
status=$?
set -e
printf 'status=%s\n' "$status"
printf 'quoted=%q\n' "$line"
printf '%s\n' "$line" | od -An -t x1

Repository: conciv-dev/conciv

Length of output: 423


🌐 Web query:

man7 pgrep -c count exit status no matches outputs 0

💡 Result:

The pgrep command's exit status and output behavior regarding counts are defined as follows: Exit Status: By default and when using the --count (-c) option, pgrep uses the following exit codes [1]: - 0: One or more processes matched the criteria [2][1]. - 1: No processes matched [2][1]. - 2: Syntax error in the command line [2][1]. - 3: Fatal error, such as out of memory [2][1]. Output for --count (-c): When the --count (-c) option is used, pgrep suppresses the list of PIDs and instead prints the total count of matching processes to standard output [1]. If the count is zero (i.e., no processes match), pgrep will output 0 and exit with a non-zero exit status (specifically 1) [1].

Citations:


Prevent duplicate zero counts in the sampler output.

When no Chromium process matches, pgrep -c chrom outputs 0 and returns status 1. The fallback appends another 0, which inserts a newline into the sampler record. Store the count with || true, then use ${chrom_count:-0}.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml at line 147, Update the sampler command around the
Chromium process count to capture pgrep’s output while preventing its nonzero
status from triggering the fallback, then emit ${chrom_count:-0} so no-match
cases produce exactly one zero without a newline.

@omridevk

Copy link
Copy Markdown
Contributor Author

Obsolete: the strand's root cause was fixed in #433 (per-icon lucide imports shrank the cold-start transform burst ~70%; CI hammer 0-strand in 10 attempts). The concurrency cap was a timing mitigation for the same failure and is no longer needed.

@omridevk omridevk closed this Aug 12, 2026
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