Skip to content

perf(covgate,covratchet): restore NumCPU default and add progress#32

Merged
ben-miru merged 3 commits into
mainfrom
perf/restore-parallelism-and-progress
May 18, 2026
Merged

perf(covgate,covratchet): restore NumCPU default and add progress#32
ben-miru merged 3 commits into
mainfrom
perf/restore-parallelism-and-progress

Conversation

@ben-miru

Copy link
Copy Markdown
Contributor

Summary

  • Reverts the CI wall-clock regression introduced by perf(covgate,covratchet): cap child GOMAXPROCS to avoid CI CPU oversubscription #28: restores the outer default to runtime.NumCPU() and drops the per-child GOMAXPROCS=max(1, NumCPU/parallelism) env injection used to start each go test invocation.
  • The premise of perf(covgate,covratchet): cap child GOMAXPROCS to avoid CI CPU oversubscription #28 was avoiding NumCPU x NumCPU oversubscription, but this repo has zero t.Parallel callsites — so the inner cap never throttled test execution, it only throttled compile/link, which is exactly the phase that dominates CI wall-clock time.
  • Adds mutex-guarded [idx/total] STATUS pkg [elapsed] progress output to covgate and covratchet when --parallelism=0 (auto mode), with a leading announcement line above the per-package table so operators can see liveness on slow runners.
  • Plan with milestones, rationale, and validation: plans/completed/20260517-restore-parallelism-and-progress.md.

Test plan

  • ./preflight.sh passes locally (includes covgate/covratchet self-lint and unit tests)
  • go test ./internal/services/covgate/... ./internal/services/covratchet/... passes
  • Manual: run covratchet --parallelism=0 against a multi-package target and confirm the announcement line plus interleaved [idx/total] STATUS pkg [elapsed] rows appear without interleaved-character corruption
  • Manual: run covgate --parallelism=0 and confirm the same progress output behavior
  • CI on this PR completes faster than the post-perf(covgate,covratchet): cap child GOMAXPROCS to avoid CI CPU oversubscription #28 baseline on a comparable run

ben-miru and others added 3 commits May 17, 2026 18:48
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ogress

Revert PR #28's two changes that combined to overshoot:
- Outer default returns to runtime.NumCPU() (was runtime.GOMAXPROCS(0)).
- Drop the per-child GOMAXPROCS env injection; child go test runs at
  Go's natural GOMAXPROCS again. The injection was motivated by
  NumCPU*NumCPU oversubscription concerns, but the repo has no
  t.Parallel call sites, so the inner cap only throttled compile/link
  and slowed CI without any safety benefit.

When --parallelism=0 (auto), emit a mutex-guarded
"[idx/total] STATUS pkg [elapsed]" line per package as workers finish,
preceded by a one-line announcement. Suppressed at explicit
--parallelism>0 so existing scripted invocations are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Plan was moved to completed/ but its milestone checkboxes still read
[ ]. Update them to [x] to reflect that the work is done; this is a
cosmetic doc-hygiene change with no code impact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ben-miru ben-miru merged commit 4f93687 into main May 18, 2026
3 checks passed
@ben-miru ben-miru deleted the perf/restore-parallelism-and-progress branch May 18, 2026 02:17
ben-miru added a commit that referenced this pull request May 18, 2026
## Summary

Follow-up to #32. The live progress block and the alphabetical recap
table carried the exact same per-package rows, doubling output without
adding information — the user reported "the spacing is off" and then
"the first and second table give exact same information, please only
show first table".

Now, when `--parallelism=0`:

- The streamed progress block (with the new leading `COUNT` column under
`[N/total]`) is the single canonical table.
- Per-package rows print only once, in completion order.
- The second `STATUS` header and reprinted rows are removed.
- FAIL detail (multi-line raw test output for `testErr` cases) still
prints after the stream — that's not duplicated data.
- `--exclude` SKIPPED rows still print, indented under the `COUNT`
column so they align with the progress table's `STATUS` column.

Non-progress mode (`--parallelism>0`) is unchanged: a single
alphabetical table, no progress stream.

## Before (current `main`)

```
Running 27 packages with parallelism=22; progress will appear as packages finish:
STATUS   COVERAGE  REQUIRED      TIME  PACKAGE
-------  --------  --------  --------  -------
[8/27] PASS  internal/pkg/openapi/server  0.8s            <- columns don't align
...
PASS         0.0%      0.0%      0.8s  internal/pkg/openapi/server   <- same data again
...
```

## After

```
Running 27 packages with parallelism=22; progress:
COUNT    STATUS   COVERAGE  REQUIRED      TIME  PACKAGE
-------  -------  --------  --------  --------  -------
[ 8/27]  PASS         0.0%      0.0%      0.8s  internal/pkg/openapi/server
[21/27]  PASS         0.0%      0.0%      1.1s  internal/pkg/server/response
...
[27/27]  PASS         0.3s  ...

Total time: 5.4s
All packages meet minimum coverage requirement
```

With `--exclude`, SKIPPED rows appear indented under the COUNT column:

```
[ 1/10]  PASS        62.7%     62.3%      0.3s  internal/commands
[10/10]  PASS         0.0%      0.0%      0.3s  internal/testutil
         SKIPPED       ---       ---       ---  internal/services/lint
         SKIPPED       ---       ---       ---  internal/services/lint/linter
         ...

Total time: 0.3s
All packages meet minimum coverage requirement
```

## Notes

- `progressColWidth(total)` scales the COUNT column with package count:
`[ 8/27]` is 7 chars for 27 packages, `[ 88/100]` is 9 for 100.
- Extracted `writeRunHeader` in both packages to keep `run()` under the
50-line `funclen` limit after the bracketing/header logic was added.
- `restOfOutput` is the dual of `firstLine` — used in progress mode to
print only the trailing FAIL detail of `checkResult.output`, not the row
that was already streamed.
- Test assertions updated: `STATUS` header appears exactly once
(progress IS the table); a `COUNT` header is present in progress mode
and absent otherwise; progress lines must carry full row data.

## Test plan

- [x] `go test ./internal/services/covgate/...
./internal/services/covratchet/...` passes
- [x] `./scripts/preflight.sh` ends with `=== All checks passed ===`
- [x] Smoke-tested `go run ./cmd/miru covgate
--packages="./internal/..." --src-prefix=internal --parallelism=0` —
single table, no duplicate
- [x] Smoke-tested same with `--exclude=./internal/services/lint/...` —
SKIPPED rows render indented under COUNT

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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