Run CI's `pyright` with 3 workers and a 6 GB Node heap so no worker empties its type cache

Merged
DO
1mo ago
+17-3

Why we make these changes

The full Pyright step in quality checks grew from a median of about 178 s (2026-10-08 to 14) to about 244 s (2026-10-26 to 28), up to 327 s, as the checked Python grew from 851k to 1,095k lines. Item 4 of #8182 predicted the cause of the extra cost: each Pyright process empties its whole type cache once its heap passes 90% of Node's default limit (about 4 GB on the runners), then re-evaluates everything it still needs. #8182 suggested raising the heap on CI but had not tested it. This PR tests it and applies it. It does not close #8182, which covers other levers.

Measured on ubuntu-latest (4 vCPU, 16 GB) with a temporary --verbose profiling workflow (runs 1, 2, 3). The workflow is not part of this PR:

configcache evictions per runwallmemory
--threads auto (4 workers), default heap: today7 to 33159 to 253 sfits
4 workers, 6 or 8 GB heap0145 to 249 s1 to 3 GB of swap
3 workers, default heap27 to 33227 to 311 sfits
3 workers, 6 GB heap0141 to 221 sfits, about 15 GB peak
1 process, 8 GB heap22239 to 314 sfits

Runner speed varies widely, so the decision rests on paired ABBA runs: today's config and the candidate ran twice each on the same runner, across 6 runners. The candidate was faster on every runner, by 9 to 14% (18 to 32 s) of the per-runner mean. All 12 candidate runs beat both baseline runs on their runner. Every run in every configuration reported 0 errors.

The growth itself is legitimate: tests went from 562k to 758k lines and pydantic_ai_slim from 154k to 189k. No single file explains it, though tests/test_embeddings.py costs 5 to 15 s because it pulls in transformers. This PR leaves PYRIGHT_TIME_BUDGET at the 320 s that #11652 set; this saving goes on top of that.

New public surface

None.

What changed

  • .github/workflows/ci.yml: the Pyright step sets PYRIGHT_THREADS: "3" instead of auto and adds NODE_OPTIONS: --max-old-space-size=6144, which every worker process inherits.
  • docs/contributing.md: states CI's setting and explains the type-cache eviction, with the measured single-process numbers.

Verification

  • The CI profiling runs linked above. No full Pyright run was done locally.
  • pre-commit on the changed files (YAML, zizmor, codespell).
  • This PR's own quality checks run used the new settings, because ci.yml is a pyright_changed input. Its Pyright step passed in 229 s. That is one sample, inside the runners' spread.

What changes for existing users

Nothing; only CI's Pyright step changes.

PR decisions
  • 2026-10-29: three pre-push reviews (budget exhausted). Review 1 could not read the policy base and contributed only a wording note. Review 2 caught that main had already raised the budget to 320 s (#11652). The branch was rebased and the budget sentence dropped. Review 3 asked for measured numbers in the docs, which were added.
  • 2026-10-29: the budget is kept at 320 s rather than lowered on the strength of this saving. That is a maintainer call.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.