Skip to content

[ci-coach] Rebalance cgo.yml unit-test matrix shards for better parallelism #60276

Description

@github-actions

CI Optimization Proposal

Summary

Pre-flight validation passed (deps-dev, lint, lint-errors, npm-ci, build, recompile, test-unit all ok: true), so this run focused on optimization. Analysis of cgo.yml's unit-test matrix showed a significant shard imbalance that was flagged (but not previously merged) by a prior ci-coach run.

Top Optimization

Rebalance cgo.yml unit-test matrix shards

  • Type: Test suite restructuring / matrix strategy
  • Impact: Reduces the longest-running shard from ~105.8s to ~54.2s (~49% reduction), shortening the critical path of the 5-way test job in cgo.yml.
  • Risk: Low — pure shard-repartitioning of existing -run regex patterns; no tests added/removed/skipped. Full A–Z coverage verified with zero gaps or overlaps.
  • Changes: .github/workflows/cgo.yml matrix include list.
  • Rationale: The old A-C shard combined the two heaviest letters (A ~46.5s + C ~54.2s = ~105.8s) into one shard, over 2x the next-heaviest shard (D-G ~42.4s). This made it the bottleneck for the whole job. Using per-letter elapsed-time data from a real test-unit run (10,602 top-level tests, ~241s total), letters were repacked via greedy (LPT) bin-packing into 5 shards:
    • A alone (~46.5s)
    • C alone (~54.2s)
    • B,E,I,P,T,U,V (~47.6s)
    • D,H,J,M,N,Q,S,W,Y (~46.3s)
    • F,G,K,L,O,R,X,Z + non-letter-prefixed tests (~46.3s)
Coverage verification

Simulated the new regex patterns against all 10,602 real top-level test names extracted from /tmp/gh-aw/agent/test-results.json:

A                         46.45s   620 tests
C                         54.15s  1247 tests
B-E-I-P-T-U-V             47.58s  3730 tests
D-H-J-M-N-Q-S-W-Y         46.29s  2262 tests
F-G-K-L-O-R-X-Z+other     46.30s  2743 tests
UNMATCHED                  0.00s     0 tests
total tests matched: 10602 (matches full test count)

No unmatched/duplicated letters across A–Z.

Expected Impact

~49% reduction in max-shard duration for the cgo.yml unit-test job, shrinking overall wall-clock time for that job stage.

Validation Results

  • YAML parsed successfully (js-yaml), matrix structure inspected and confirmed.
  • Regex coverage simulated against real test-name data (10,602/10,602 tests matched, zero gaps/overlaps).
  • go build/go test are blocked in this sandbox by a proxy.golang.org 403 (network restriction unrelated to this YAML-only change) — pre-flight validation-status.json already confirmed lint/build/test-unit passed on the base commit before this run began.
  • No Go/CLI code touched; only the shard pattern/shard/name fields in cgo.yml's test job matrix were changed.

Metrics Baseline

  • Total unit test time across matrix: ~241s (unchanged — same tests, same total work)
  • Old max shard: ~105.8s (A-C)
  • New max shard: ~54.2s (C)

Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the change modifies protected files. A human must create the pull request manually.

Protected files

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the artifact from the workflow run
gh run download '34603719476' -n agent -D '/tmp/agent-34603719476'

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-34603719476/aw-ci-coach-rebalance-cgo-unit-shards-20260911.bundle'
temp_ref='refs/bundles/create-pr-ci-coach-rebalance-cgo-unit-shards-20260911-73bf9170ab771529-d5d6d1f0'
target_ref='refs/heads/ci-coach/rebalance-cgo-unit-shards-20260911-73bf9170ab771529'
bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 ~ /^refs\/heads\// { print $2 }')
if [ -z "$bundle_source_ref" ]; then
  bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 == "HEAD" { print $2 }')
fi
if [ "$(printf '%s\n' "$bundle_source_ref" | sed '/^$/d' | wc -l | tr -d ' ')" != "1" ]; then
  echo "Expected exactly one bundle source ref, found: $bundle_source_ref" >&2
  exit 1
fi
git fetch "$bundle_path" "${bundle_source_ref}:${temp_ref}"
git update-ref "$target_ref" "$temp_ref"
git checkout 'ci-coach/rebalance-cgo-unit-shards-20260911-73bf9170ab771529'
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d "$temp_ref"

# Push the branch and create the pull request
git push origin ci-coach/rebalance-cgo-unit-shards-20260911-73bf9170ab771529
gh pr create --title '[ci-coach] Rebalance cgo.yml unit-test matrix shards for better parallelism' --base main --head ci-coach/rebalance-cgo-unit-shards-20260911-73bf9170ab771529 --repo github/gh-aw

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by CI Optimization Coach · copilot · auto · 96 AIC · ⌖ 20.3 AIC · ⊞ 17K ·

  • expires on Sep 13, 2026, 5:42 AM UTC-08:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions