Skip to content

[ci-coach] Rebalance cgo.yml unit-test matrix shards by actual per-letter duration #59987

Description

@github-actions

CI Optimization Proposal

Summary

Pre-flight validation (deps-dev, lint, lint-errors, npm-ci, build, recompile, test-unit) all passed on the base commit. ci-summary.json showed a healthy pipeline, so this run focused on Phase 3 (test suite restructuring). Analysis of test-results.json (10,625 top-level tests) found the cgo.yml unit-test matrix's A-C shard was significantly imbalanced against its 4 sibling shards.

Top Optimization

Rebalance cgo.yml unit-test matrix shards

  • Type: Test suite restructuring / matrix strategy
  • Impact: Longest shard reduced from ~99s to ~51s (~48% cut in test-job critical path)
  • Risk: Low — regex-only change, no test code touched, full A-Z coverage verified
  • Changes: Split the old A-C bucket (98.96s combined, dominated by A=45.2s and C=50.81s with B at only 2.95s) into separate A and C shards, and rebalanced the remaining 23 letters across 3 shards using LPT bin-packing on aggregated per-letter durations:
    • A (~45.2s)
    • C (~50.81s)
    • D,E,H,O,T,U (~43.4s)
    • F,I,K,M,S,V,W (~43.5s)
    • B,G,J,L,N,P,Q,R,X,Y,Z (~42.2s)
  • Rationale: The old split treated adjacent letters as roughly equal-cost, but real test durations are highly skewed (e.g., TestCommandLine*-style heavy suites cluster under C). Aggregating actual elapsed time per letter and applying LPT bin-packing produces a materially tighter spread (42–51s vs. the previous 22–99s range) without touching test code or matrix job count.

Expected Impact

Flattens the 5-way test job duration variance in cgo.yml, cutting the longest-shard wall-clock time roughly in half and reducing idle time on faster shards, which shortens the overall PR feedback loop.

Validation Results

  • YAML parsed successfully (local js-yaml via Node).
  • Verified zero pattern gaps/overlaps across A-Z and confirmed all 10,625 real top-level test names from test-results.json map to exactly one shard (counts: A=618, C=1239, D-E-H-O-T-U=1760, F-I-K-M-S-V-W=3310, Other=3698; sum matches total).
  • go build / make recompile / make test-unit could not be executed in this sandbox because proxy.golang.org returned 403 Forbidden (network restriction unrelated to this change, also noted in the prior ci-coach run's cache memory).
  • Pre-flight validation-status.json already confirmed build, recompile, and test-unit passed on the base commit before this run began; this change only edits matrix pattern/shard string literals, with no Go code or job-dependency changes.

Metrics Baseline

Shard Old duration New duration
A-C (old) / A, C (new) 98.96s 45.2s / 50.81s
D-G (old) / D,E,H,O,T,U (new) 37.30s ~43.4s
H-M (old) / F,I,K,M,S,V,W (new) 37.86s ~43.5s
N-R (old) / Other (new) 22.53s ~42.2s
S-Z+other (old) 28.49s (merged above)

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

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-34481867757/aw-ci-coach-rebalance-cgo-unit-test-shards-20260910.bundle'
temp_ref='refs/bundles/create-pr-ci-coach-rebalance-cgo-unit-test-shards-20260910-1931102e88fc9284-9ec034af'
target_ref='refs/heads/ci-coach/rebalance-cgo-unit-test-shards-20260910-1931102e88fc9284'
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-test-shards-20260910-1931102e88fc9284'
# 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-test-shards-20260910-1931102e88fc9284
gh pr create --title '[ci-coach] Rebalance cgo.yml unit-test matrix shards by actual per-letter duration' --base main --head ci-coach/rebalance-cgo-unit-test-shards-20260910-1931102e88fc9284 --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 · 101 AIC · ⌖ 23.5 AIC · ⊞ 17K ·

  • expires on Sep 12, 2026, 5:39 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