Repository navigation
Description
Problem
The startup-imports row of devops ci (#2164) starts 55 fresh interpreters. Over three runs on one host it used 57 to 71 s of CPU time (53 to 64 s user). The 57 pytest tests that it replaces used 76 to 129 s. #2369 set the goal at half of the old CPU time, by a cut of the import of devops_cli.main or of the work of the help. The row moves the cost and runs four probes at a time, so it does not reach the goal.
The cost split of #2369: a bare interpreter costs 0.03 s, and import devops_cli.entry costs 0.25 to 0.36 s. The rest is the work of main and of the help of each command group.
Proposed solution
- Measure the import of
devops_cli.mainand the work of the help of each command group withtests/gate/startup_imports.py(it prints the CPU time and, for a failed run, the ten slowest imports). - Cut the largest import or the largest piece of work in the help, so that the CPU time of the row is at most half of 76 s.
- Keep the four module limits, the control and
-X importtime.
Existing tool considered
python -X importtime and the row itself measure the cost. Nothing is built.
Acceptance criteria
- The row
startup-importsuses at most 38 s of CPU time (user plus system) over three runs on one host. - The limits and the control are as before.
Alternatives check of 2026-11-07: not-applicable.
Class: perf, no search.
Tool: none found.
Proposed design
Problem statement
The startup-imports row of devops ci starts 55 fresh interpreters and uses 57 to 71 s of CPU time. The old 57 pytest tests used 76 to 129 s. The issue sets the goal at 38 s, half of the 76 s lower bound. The row reports the cost but does not cut it.
Acceptance criteria
Requirement: Startup import CPU budget
The startup-imports row SHALL use at most 38.0 s of child CPU time on each of three consecutive runs on one host.
Scenario: Three consecutive runs
- WHEN A developer runs the
startup-importsrow ofdevops cithree times on the same host. - THEN Each run prints a child CPU time of at most 38.0 s and exits 0.
Requirement: Lazy command help
The root help SHALL import no command implementation module.
Scenario: Root help loads no command implementation
- WHEN A fresh interpreter runs
devops_cli.entry.main(["--help"]). - THEN No module whose name starts with
devops_cli.commands.is insys.modules.
Requirement: Complete command help
The root help SHALL list every command name that _COMMAND_SPECS holds.
Scenario: Root help lists all commands
- WHEN A fresh interpreter runs
devops_cli.entry.main(["--help"]). - THEN The output contains each command name from
_COMMAND_SPECS.
Requirement: Startup import limits
The four startup-import module limits SHALL stay at 550, 75, 1100 and 250.
Scenario: Limits unchanged
- WHEN A test reads the four
DEFAULT_STARTUP_IMPORT_*constants. - THEN The values are 550, 75, 1100 and 250.
Requirement: Heavy import control
The control probe MUST still fail a help run that imports pydantic_ai.
Scenario: Control catches a heavy import
- WHEN The control runs
--helpafterimport pydantic_ai. - THEN
control_problemsreturns an empty list for a probe that loadspydantic_aiand more than 550 modules.
Requirement: Importtime flag
Each help probe SHALL run under python -X importtime.
Scenario: Importtime remains
- WHEN A test reads the argument list that
probe_startup_importspasses tosubprocess.run. - THEN The argument list contains
-Xandimporttime.
Existing Tool Considered
No open, maintained tool covers this. The alternatives check returned not-applicable for a perf item and named no tool. python -X importtime and tests/gate/startup_imports.py measure the cost but do not cut it. The change builds no new tool; it changes the existing CLI and probe.
Key questions
- Where does the row report its CPU time?:
tests/gate/startup_imports.pyreadsresource.getrusage(resource.RUSAGE_CHILDREN)after all probes and prints user plus system child CPU time. [sources: tests/gate/startup_imports.py] - Which probes does the row run for the help?:
help_argvs()returns--version, the root--help, each command in_COMMAND_SPECS, and every argv in the budget and telemetry tables. Each probe starts a fresh interpreter, importsdevops_cli.entry, callsentry.main, and runs under-X importtime. [sources: tests/gate/startup_imports.py, src/devops_cli/entry.py:28] - How should the change cut the CPU time?: Make the command registry in
src/devops_cli/main.pylazy. Keep each command name and its help text in data, and import the command implementation module only when the command runs. The help probes then import command metadata only. (best practice) [sources: tests/gate/startup_imports.py, src/devops_cli/main.py, src/devops_cli/entry.py:28]- Chosen: Lazy command registry. It cuts the import of command implementation modules from every help probe and keeps all probes and limits.
- Rejected: Fewer help probes. It reduces coverage of command groups and hides a regression in an untested help.
- Rejected: More parallel probes. It cuts wall time, not CPU time, and the row already runs four probes at a time.
- What CPU budget should the row enforce?: Use 38.0 s of child CPU time, half of the 76 s lower bound of the old pytest suite. Add
CPU_BUDGET_SECONDS = 38.0totests/gate/startup_imports.pyand makemainreturn 1 when the measured child CPU time is greater. (best practice) [sources: tests/gate/startup_imports.py]- Chosen: Enforce 38.0 s. It is the issue's goal and makes the row fail when the cost returns.
- Rejected: Report only. A report does not stop the row from returning above the goal.
- Rejected: Enforce wall time. The issue sets CPU time as the metric; wall time depends on host load.
- Should the change reduce the number of help probes to reach the budget?: No. Keep every help argv, the four module limits, the control and
-X importtime. Cut the per-probe import cost with the lazy registry. (best practice) [sources: tests/gate/startup_imports.py]- Chosen: Keep every probe. It keeps coverage of every command group and follows the issue's constraint.
- Rejected: Sample command groups. It hides a regression in an untested command group.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 4, 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.(cli)scope of the title gives the scope.The row misses its goal by a large margin but nothing is broken, so it is a medium-priority optimization.Saving 19 to 33 s of CI CPU time per run has real cost and speed value for contributors.It needs measuring the import chain, finding the largest slice, and refactoring it while keeping the limits intact.Both target the startup-imports row CPU time, but #2369 cut the number of interpreter starts while this item cuts the per-start import and help cost.ci(gate): run the checks of committed files as devops ci rows (#3557)
devops-cli-service commentedon Nov 6, 2026
Refine cannot set this item to Ready at c1191e2 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
devops-cli-service commentedon Nov 7, 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-07. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 13, 2026
Status set to Ready at 4ef7c6f (see proposed design in issue body).
21 remaining items
devops-cli-service commentedon Nov 15, 2026
Cleared the stop at scoped checks by the rule
digest: the runner image changed since the stop, from sha256:98de20a7edd09701e7b226a1931ada4763199253d241daf1151b0fe6b79f2dc5 to sha256:014636e1131ac1400a333cf938c841f3ffff1b3a7deb8b63b92cb8920cd31745, and the classci_infraof the stop is one that a new attempt can fix. The item is Planned again, and the Service takes it in the next round. The Service clears at most 1 for each class and 3 for each item by digest. A stop of another class, a new stop on this image, and a stop over a limit wait for a commentimplement: retry.perf(cli): Load the dry-run names on first use (#3550)
perf(cli): Build the version record without pydantic (#3550)
perf(cli): Build the help catalog alone at start (#3550)
perf(cli): Report each probe's CPU and refuse pydantic in the root he…
perf(cli): Name the pydantic rule of the row in the testing guide (#3550
docs(openspec): archive the change (#3550)
test(lang): cover English language pack dynamic exports (#3550)
devops-cli-service commentedon Nov 16, 2026
Released in v0.160.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.160.0
devops-cli-service commentedon Nov 16, 2026
Live since 2026-11-16 03:02 UTC