Skip to content

[ci-coach] Rebalance cgo.yml unit-test matrix shards for faster critical path #60846

Closed as not planned

Description

@github-actions

CI Optimization Proposal

Summary

The cgo.yml unit-test job splits Go tests into 5 alphabetical shards (A-C, D-G, H-M, N-R, S-Z+other) that run in parallel. Real per-test timing data from the current run (/tmp/gh-aw/agent/test-results.json, 10,637 top-level tests) showed the split was badly imbalanced: shard A-C alone took ~64.8s while the other four shards ranged only 23-43s. Since all shards run in parallel, the job's critical path is bounded by the slowest shard — so A-C was the bottleneck every run.

Top Optimization

Rebalance cgo.yml unit-test matrix shards

  • Type: Test Suite Restructuring (matrix strategy)
  • Impact: Cuts the unit-test job's critical path from ~64.8s (max shard) to ~52.4s — a ~19% reduction in wall-clock time for that job, with no change in total test count or coverage.
  • Risk: Low. Only the pattern/name/shard fields of the existing 5-way matrix changed; job structure, concurrency groups, and dependencies are untouched.
  • Changes: Applied longest-processing-time (LPT) bin-packing across all 26 letters using real per-letter test durations:
    • C isolated (52.4s — dominated by TestConfig*/TestCompil* tests)
    • A-E-M-O-W (35.8s)
    • B-H-J-K-N-S (35.6s)
    • D-G-L-P-V (35.7s)
    • F-I-Q-R-T-U-X-Y-Z + non-letter test names (35.6s)
  • Rationale: The old alphabetical split assumed uniform test-name distribution, but Go test names cluster heavily around common prefixes (TestC... for Config/Compile-related code). LPT bin-packing on measured durations produces near-equal shard times without needing more matrix jobs.

Expected Impact

  • Max shard duration: ~64.8s → ~52.4s (~19% faster critical path for the unit-test job)
  • No change in job count (still 5 parallel shards), no change in coverage

Validation Results

  • ✅ YAML syntax validated (js-yaml)
  • ✅ All 5 new regex patterns simulated against all 10,637 real test names: 100% coverage, 0 unmatched, 0 duplicate matches
  • ⚠️ make build/make recompile blocked in this sandbox by proxy.golang.org 403 (pre-existing network restriction, unrelated to this YAML-only change — confirmed via pre-flight validation-status.json that build/test-unit already pass on the base commit)

Metrics Baseline

  • Source: /tmp/gh-aw/agent/test-results.json (this run's go test -json output, 10,637 top-level tests)
  • Old shards: A-C=64.8s, D-G=42.6s, H-M=36.9s, N-R=23.1s, S-Z+other=27.7s
  • New shards: C=52.4s, A-E-M-O-W=35.8s, B-H-J-K-N-S=35.6s, D-G-L-P-V=35.7s, F-I-Q-R-T-U-X-Y-Z+other=35.6s

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 '34848847278' -n agent -D '/tmp/agent-34848847278'

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-34848847278/aw-ci-coach-rebalance-cgo-unit-shards-93155.bundle'
temp_ref='refs/bundles/create-pr-ci-coach-rebalance-cgo-unit-shards-93155-efbbce04885d8c34-6d037e4e'
target_ref='refs/heads/ci-coach/rebalance-cgo-unit-shards-93155-efbbce04885d8c34'
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-93155-efbbce04885d8c34'
# 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-93155-efbbce04885d8c34
gh pr create --title '[ci-coach] Rebalance cgo.yml unit-test matrix shards for faster critical path' --base main --head ci-coach/rebalance-cgo-unit-shards-93155-efbbce04885d8c34 --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 · 82.6 AIC · ⌖ 19.7 AIC · ⊞ 17K · ◷

  • expires on Sep 16, 2026, 5:43 AM UTC-08:00

Activity

  1. github-actions commented on Sep 16, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-09-16T13:43:36.327Z.

    Closed by Workflow

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