Skip to content

perf(roadmap): parse only the test modules that name the registry - #4778

Merged
dan-petty merged 4 commits into
mainfrom
perf/4509-registry-token-check
Nov 11, 2026
Merged

dan-petty merged 4 commits into
mainfrom
perf/4509-registry-token-check

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

When a caller of check_proposal or check_gates gives no table, the registry gate calls registry_table, which ran ast.parse on each of the 1,340 test modules on each call (2 to 4 s).

counts_in now returns no entry before ast.parse when the text does not hold REGISTRY_COUNTS. A declaring module holds that name, so the table does not change, and only 7 modules are parsed. The stage gate tests pass registry=(), and the limit ratchet test gives the table of the checkout. A test sees the ast.parse calls through sys.monitoring and patches nothing.

Closes #4509

Change: openspec/changes/archive/2026-11-11-4509-parse-only-the-test-modules-that/

counts_in returns no entry before ast.parse when the text of the module
does not hold REGISTRY_COUNTS. A module that declares the counts assigns
to that name, so the table does not change. registry_table makes the
relative path only for a module that gives an entry.

A test sees the calls of ast.parse through sys.monitoring (PEP 669) and
patches no function.
Each call of check_proposal, check_gates and gate_arguments in
tests/roadmap/stage that does not test the registry gate passes
registry=(), so a test of another gate does not read the declarations
of the tree. The test of a new roadmap limit gives the table of the
checkout, because it checks a real declaration.
@dan-petty dan-petty added type/infra Type infra: the build, CI, images or cluster scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 11, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Measurements (local, 16 CPUs, Python 3.14.10)

The host had other load. The load average is given for each run.

What Before (origin/main) After (this branch)
registry_table on the checkout, median of 5 calls, interleaved, load 15-16 4.282 s 0.166 s
Entries of the table 7 (4 modules) the same 7 entries
tests/roadmap/implement, -n 6, no coverage: sum of test time 4,085.5 s (load 15-26) 1,117.3 s (load 15)
tests/roadmap/implement: pytest wall time 744.9 s 204.3 s
tests/roadmap/stage, -n 6, no coverage: sum of test time 2,483.8 s (load 13-26) 644.1 s (load 13-15)
tests/roadmap/stage: pytest wall time 461.8 s 135.3 s
  • The implement row falls by 72.7%. The CI audit measured 2,534 s for this row at a lower load and set 900 s as the target. The relative cut is the same as the cut of the per-process cache in the audit (-72%).
  • Only 7 of the 1,340 modules under tests/ hold REGISTRY_COUNTS. ast.parse of these 7 modules is about 0.05 s of the 0.166 s.
  • The sum of the shard pytest times and the Changed-Test Independence time come from the CI runs. I add them when the runs of this pull request end.

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main (exit 0):

failed on base: tests.roadmap.stage.test_roadmap_stage_registry::test_a_module_that_does_not_name_the_counts_is_not_parsed (AssertionError: assert ['def test_pl...ssert True\n'] == [])
1 failed on base (1 failed and 673 passed in tests/roadmap/stage/...)

Scope

  • The issue design also asked for a conftest.py guard in tests/roadmap/stage/ that replaces registry_table in stage_change and raises. This pull request does not build it. docs/TESTING.md (Doubles) says that no test patches a devops-cli function, and fix(roadmap): judge the registry of the checked-out tree #4695 makes registry a required argument of check_gates and check_proposal, so the interpreter will refuse a call with no table. The design of the change records this.
  • The issue design also asked for a test that counts ast.parse in check_proposal with registry=[]. That test passes on the base, because that path builds no table, and other gates also parse Python text. The design records this too.

Owner steps

None. The change touches no workflow, setting, manifest or the cluster.

@dan-petty

dan-petty commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner Author

CI measurements

All runs are CI Quality Gate runs of the pull_request event. The pytest time of a shard is the passed in N s line of its Tests & Coverage job log. Changed-Test Independence is the job time (completed_at minus started_at) from the Actions API.

Run Shard 1 Shard 2 Shard 3 Shard 4 Sum of shard pytest times Changed-Test Independence
43018712031 (CI audit baseline) 316.7 s 316.7 s 158.2 s 371.1 s 1,162.7 s 618 s
Mean of the 5 last green PR runs before this change (43081069892, 43078687964, 43078326538, 43076061309, 43075308207) 1,321.1 s (1,245.3-1,417.9 s) 42-531 s
43082105405 (this pull request, head b7b5a46) 244.2 s 189.6 s 125.1 s 153.8 s 712.7 s 98 s
  • The sum of shard pytest times falls by 38.7% from the audit baseline, and by 46.1% from the mean of the 5 last PR runs. The target is a cut of 20% or more.
  • The slowest shard falls from 371.1 s (audit baseline) and 522-594 s (the 5 last PR runs) to 244.2 s.
  • Changed-Test Independence ran the 17 changed test modules of this pull request, all in tests/roadmap/stage/, in 98 s. The audit measured 614-685 s, and 181 s of a 205 s run were in 130 table builds. The target is 300 s or less.
  • This is one run. The acceptance of the issue asks for 5 PR runs. The PR runs after the merge give the other 4.

@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 19:12
@dan-petty
dan-petty enabled auto-merge (squash) November 11, 2026 19:12
@dan-petty
dan-petty merged commit 4b28980 into main Nov 11, 2026
32 checks passed
@dan-petty
dan-petty deleted the perf/4509-registry-token-check branch November 11, 2026 19:19
dan-petty pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.113.0](v0.112.3...v0.113.0)
(2026-11-11)


### Features

* **roadmap:** detect merge conflicts on open ready pull requests
([#4766](#4766))
([3f72e76](3f72e76))


### Bug Fixes

* **ci:** run the job-time alarm on the schedule only
([#4774](#4774))
([60c0847](60c0847))


### Performance Improvements

* **roadmap:** parse only the test modules that name the registry
([#4778](#4778))
([4b28980](4b28980))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/infra Type infra: the build, CI, images or cluster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(test): stage gate tests parse every test file per call

1 participant