Repository navigation
Description
Problem or Motivation
Acceptance criterion 2 of #4700 is not met as far as the measurements show: "The 4 heaviest files run in 15 s or less with -n 4 and no coverage (from 26.5 s, measured)". #4700 is closed as completed by #4850, and no follow-up issue holds the costs that stay.
The 4 files: tests/invariants/test_source_tree.py, tests/telemetry/test_telemetry_instruments.py, tests/invariants/test_hermetic_floor.py, tests/invariants/test_architectural_invariants.py.
Measurements (command: uv run pytest -n 4 -p no:cov -q --durations=20 <the 4 files>; the time is the pytest passed in value):
On 2026-11-12, in the devcontainer, with a load average of 34 to 44 on 16 CPUs. "Before" is 66c9ef5a (the parent of the merge), "after" is 7a163a72 (the merge of #4850). The runs alternate in ABBA order.
| Run | Tree | pytest time | CPU (user + sys) |
|---|---|---|---|
| 1 | before | 543.9 s | 1,135.8 s |
| 2 | after | 376.8 s | 850.4 s |
| 3 | after | 331.3 s | 699.4 s |
| 4 | before | 468.9 s | 916.2 s |
The mean goes from 506.4 s to 354.0 s (ratio 0.699). The CPU time goes from 1,026.0 s to 774.9 s (ratio 0.755). The builder of #4850 measured the ratio 0.719 (229.0 s to 164.6 s). With these ratios, the baseline of 26.5 s becomes 18.5 s to 20.0 s. That is more than the target of 15 s. The host was loaded, so the absolute values are not valid; only the ratio is.
The CI logs give no time for each test file, and the shard times of #4850 (sum 975 s, against 908-990 s on recent runs) do not show the change.
Costs that stay in the after tree (from --durations of the after runs above):
- Each of the 4 xdist workers parses all of
src/once, in the setup of the session fixtureparsed_source_trees. Setups of 38 s to 68 s under load:test_commands_leave_the_report_of_a_devops_error_to_the_exit_seam(test_source_tree.py),test_the_source_tree_keeps_its_structural_invariants,test_no_direct_data_dir_path_construction_in_src,test_every_source_file_is_parsed_at_most_once(test_architectural_invariants.py) andtest_no_gauge_reaches_prometheus_through_two_paths(test_telemetry_instruments.py). - The telemetry walks:
test_every_metric_is_a_declared_instrument_sent_through_emit(27 s to 40 s of call time under load),test_no_gauge_reaches_prometheus_through_two_paths(22 s) andtest_no_emit_sends_an_attribute_that_the_resource_sets(22 s). - The in-process
pytesterruns oftest_hermetic_floor.py: 15 s to 23 s of call time each under load, for exampletest_a_config_write_outside_the_run_fails_at_the_write_naming_the_testandtest_tokenizer_cache_points_to_the_recorded_directory.
Proposed Solution & Architectural Design
Rule 2 first: measure the 4 files on a quiet host (or in one CI job with --durations=0) and record the absolute time. If it is 15 s or less, close this item with the evidence.
Else, lower the costs that stay, with the parse cache and the test-tree row that exist:
- One
src/parse in each xdist worker: the session fixtureparsed_source_trees(tests/support/trees.py) parses all ofsrc/once in each worker. Put the checks that walk all ofsrc/into fewer workers (for example onexdist_group), or move them to adevops citree row that parsessrc/once. - The telemetry walks of
test_telemetry_instruments.py(gauge, metric and emit checks): move them to the tree row, or make one walk that collects the three tables. - The in-process
pytesterruns oftest_hermetic_floor.py(16 tests): each inner run loads the root conftest, which registers every module oftests.supportas a plugin, so each run imports and rewrites those modules again. The profile of the perf(tests): parse the source trees once per worker #4850 builder counted 3,152 support-module parses. Use a smaller inner conftest, or run the floor checks in one inner session.
Risk: Low. The change touches tests and tests/gate/ only.
Target Subsystem
SDLC, Git & PR Governance (tests/invariants/, tests/telemetry/test_telemetry_instruments.py, tests/support/trees.py, tests/gate/tree_checks/).
Existing Tool Considered
The parse cache tests/support/trees.py (#1749), the test-tree row of devops ci (#2164) and pytest-xdist --dist loadgroup cover the need. No new tool. Cost: about 30,000 tokens and 2 hours.
Acceptance Criteria
- The 4 files run in 15 s or less with
-n 4 -p no:covon a quiet host or in one CI job (measured, before and after in a pull request comment). - No test keeps a check that the tree row already does.
Dependencies
None. Follows #4700.
Source: #4700
Alternatives check of 2026-11-14: not-applicable.
Class: perf, no search.
Tool: none found.
Proposed design
Problem statement
The four heaviest test files still exceed the 15 s target of #4700. Each xdist worker parses all of src/ for the session fixture parsed_source_trees. The telemetry checks walk the parsed trees three times. Each in-process pytester run of the floor loads every tests.support plugin. The change moves the whole-src/ checks to the test-tree row of devops ci, collects the telemetry tables in one walk, and gives the floor its own conftest.
Acceptance criteria
Requirement: The four files hold no whole-tree check
The four files tests/invariants/test_source_tree.py, tests/telemetry/test_telemetry_instruments.py, tests/invariants/test_hermetic_floor.py and tests/invariants/test_architectural_invariants.py SHALL hold no test that takes the parsed_source_trees fixture.
Scenario: Fixture scan of the four files
- WHEN a test parses the four files with
astand collects the fixture names of each test function - THEN the collected names contain no
parsed_source_trees.
Requirement: The test-tree row runs the moved whole-src checks
The test-tree row of devops ci SHALL run each whole-src/ check that the four files no longer hold.
Scenario: The test-tree row on the current tree
- WHEN a person runs
uv run devops ci --check --only test-tree - THEN the command exits 0 and its output lists each moved check.
Requirement: One walk collects the telemetry tables
The gauge, metric and emit checks in the test-tree row SHALL read the tables that one walk of the parsed trees collects.
Scenario: A tree map that counts its walks
- WHEN a test runs the collector over a tree map that counts each walk
- THEN the map counts one walk.
Requirement: The floor's inner runs load a floor-only conftest
Each in-process pytester run of tests/invariants/test_hermetic_floor.py MUST load only the conftest that the floor needs.
Scenario: The plugin list of an inner run
- WHEN an inner run starts with
--trace-config - THEN its output names no module of
tests.support.
Requirement: The four files run in 15 s or less
The four heaviest test files SHALL run in 15 s or less with -n 4 -p no:cov on a quiet host.
Scenario: The four files on a quiet host
- WHEN a person runs
uv run pytest -n 4 -p no:cov -q --durations=0on the four files on a quiet host - THEN pytest reports
passed inof 15 s or less.
Existing Tool Considered
The alternatives check of 2026-11-14 in the issue body gives not-applicable for class perf and names no tool. The need is covered by open, maintained tools that the project already uses: pytest-xdist, pytest's pytester, the parse cache at tests/support/trees.py:92 (#1749), and the test-tree row of devops ci (tests/gate/tree.py, #2164). pytest-xdist lacks a shared parse across workers. pytester lacks a small inner conftest. The change adds no dependency. It builds one check module for each moved subject under tests/gate/tree_checks/ and one floor conftest. Written cost: about 30,000 tokens to build, keep and fix that code, and about 2 hours elapsed.
Key questions
- Which mechanism stops the four xdist workers from parsing all of
src/?: Move each check that takesparsed_source_treesto thetest-treerow ofdevops ci. The row parsessrc/once in one process. The four files keep only checks that read text or one module. (best practice) [sources: tests/support/trees.py:92, tests/gate/tree.py, tests/gate/tree_checks/facades.py]- Chosen: Move each check that takes
parsed_source_treesto thetest-treerow. The row already parses the trees once in one process, so the moved checks add no parse and no worker. - Rejected: One
xdist_groupfor the whole-src/checks. The measurement runs only the four files, so one group puts all work in one worker and the wall time becomes the sum. - Rejected: Keep the checks in the four files. The measured ratio puts the four files at 18.5 s to 20.0 s, above the 15 s target.
- Chosen: Move each check that takes
- Which checks of
tests/invariants/test_source_tree.pytake the whole-src/parse?: Ten:test_commands_leave_the_report_of_a_devops_error_to_the_exit_seam,test_a_default_that_backs_a_setting_is_read_through_the_settings,test_one_path_validates_a_structured_reply_and_reflects_its_errors,test_the_origin_lookup_takes_its_repository_root_from_the_caller,test_no_mock_imports_in_src,test_product_code_never_reads_pytest_current_test,test_product_code_does_not_tell_a_replaced_subprocess_run_from_the_stdlib_one,test_no_mock_attribute_probes_in_src,test_no_unreachable_calls_in_srcandtest_no_direct_time_sleep_stays_in_src. The ban tests and the layout ratchets build their own small tree or read file names, so they take noparsed_source_treesfixture. [sources: tests/invariants/test_source_tree.py, tests/support/trees.py:92] - Where do the checks of the
test-treerow live, and how does a check join the row?: The row istests/gate/tree.py. Its checks are modules undertests/gate/tree_checks/, each named for its subject:facades.py,process_state.pyandtask_prompts.py. Each module reads the session fixtureparsed_source_trees. [sources: tests/gate/tree.py, tests/gate/tree_checks/facades.py, tests/gate/tree_checks/process_state.py, tests/gate/tree_checks/task_prompts.py] - How do the three telemetry checks stop walking the parsed trees three times?: Move the three telemetry checks to the
test-treerow. One walk of the parsed trees collects the gauge names, the metric writes and the emit attributes. The three checks read that result. (best practice) [sources: tests/telemetry/test_telemetry_instruments.py, tests/support/trees.py:92, tests/gate/tree.py]- Chosen: One walk in the
test-treerow collects the three tables. Each tree is read once, the three checks keep their names and messages, and no worker parsessrc/for them. - Rejected: Three walks in the row. Each walk repeats the traversal of every tree.
- Rejected: Keep the three checks in pytest. The parse and the walks stay in the four files, which the measurement puts above 15 s.
- Chosen: One walk in the
- How do the floor's in-process
pytesterruns stop loading everytests.supportplugin?: Give each inner run a floor-only conftest and set--confcutdirto the inner test directory. Pytest then does not load the root conftest. The inner run loads no module oftests.support. (best practice) [sources: tests/invariants/test_hermetic_floor.py:594, tests/conftest.py]- Chosen: A floor-only conftest with
--confcutdirfor the inner run. The inner run stops importing and rewriting the support modules, and each test keeps its own assertions. - Rejected: One inner session for all 16 floor checks. Each floor test asserts the outcome of its own inner run, so one session changes 16 assertions.
- Rejected: Leave the inner runs as they are. Each inner run loads the root conftest again, and the profile of perf(tests): parse the source trees once per worker #4850 counted 3,152 support-module parses.
- Chosen: A floor-only conftest with
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
perfprefix of the title gives the type.(tests)scope of the title gives the scope.The 15 s target is unmet but all tests pass; it is a performance gap, not a failure.Faster local and CI test runs cut developer wait time.Three separate optimizations across parse, telemetry, and pytester paths, all within test files.Both target invariant test speed and source-tree parsing, but #1749 delivered one shared parse while the candidate requires three distinct optimizations to meet the 15 s bound.devops-cli-service commentedon Nov 14, 2026
Alternatives check: not-applicable
Class: perf. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
Owner question: Who measures the four files on a quiet host, and how is the time recorded? (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 20, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
chore(main): release 0.240.1 (#7635)
devops-cli-service commentedon Nov 28, 2026
Released in v0.240.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.240.1
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 23:51 UTC