Repository navigation
Description
Problem Description
Since #6449 (PR #6505, 494de4f), open_dependency (src/devops_cli/roadmap/dependencies.py:36-52) builds the full dependency graph of all open items each time it finds an open dependency: DependencyGraph.of(items).cycle_of(item.number) at line 49. The stage judge (src/devops_cli/roadmap/stage/stage.py:774) and the implement judge (src/devops_cli/roadmap/implement/implement.py:382) call it once for each item that they judge. Refine builds the graph once for each round and passes it in, but stage and implement do not.
Measured on 2026-11-20, read only:
- One build over the 798 open items takes 3.3 s (two markdown parses of each body).
- 27 Ready items have an open
#Ndependency today. - One
devops roadmap explain 4814calledDependencyGraph.of28 times, 93.7 s in total, of 321 s.
The Service stage round runs the same selection, so each stage round spends about 90 s more CPU. The cost grows with the number of Ready items that have a dependency times the number of open items.
Also, the path search _path_back (src/devops_cli/roadmap/refine/refine.py:1347) is a last-in-first-out search that copies the path at each step. It does not give the shortest cycle: for #1 → [#2, #3], #2 → #1, #3 → #4 → #1 it names #1 → #3 → #4 → #1. A ring of 500 items takes 0.52 s, and a ring of 20,000 items did not end in 3 minutes. Live cycles have 2 to 4 items today, so this part is minor.
Reproduction Steps
- Wrap
DependencyGraph.ofwith a counter and a timer. - Run
uv run devops roadmap explain 4814. - The counter shows 28 calls and 93.7 s.
Expected vs Actual Behavior
- Expected: each selection (stage, implement, explain) builds the graph once and reuses it for each item, as refine does.
- Actual: each judged item with an open dependency builds the full graph again.
Environment Diagnostics
devops-cli at main 494de4f (2026-11-20), after #6505.
Dependencies
None.
Acceptance Criteria
- A test: a stage selection over several items that have open dependencies builds the graph once.
- The same for the implement selection.
- The cycle path is a shortest cycle through the item (breadth-first search), and a long ring does not copy the path at each step.
See #6449.
Alternatives check of 2026-11-20: not-applicable.
Class: perf, no search.
Tool: none found.
Proposed design
Problem statement
Stage, implement and explain rebuild the full dependency graph for each judged item that has an open dependency. One build over 798 open items takes 3.3 s, and one explain run built the graph 28 times for 93.7 s. The refine path search copies the path at each step and returns a longer cycle. The change builds the graph once per selection and uses breadth-first search for the shortest cycle.
Acceptance criteria
Requirement: Stage builds one graph
The stage selection SHALL build the dependency graph at most once for all judged items that have an open dependency.
Scenario: Two stage items with open dependencies
- WHEN A test wraps
DependencyGraph.ofwith a counter and runs the stage selection over two items that each have an open dependency. - THEN The counter is 1.
Requirement: Implement builds one graph
The implement selection SHALL build the dependency graph at most once for all judged items that have an open dependency.
Scenario: Two implement items with open dependencies
- WHEN A test wraps
DependencyGraph.ofwith a counter and runs the implement selection over two items that each have an open dependency. - THEN The counter is 1.
Requirement: Explain builds one graph
The explain selection SHALL build the dependency graph at most once for all items that it explains with an open dependency.
Scenario: Two explain items with open dependencies
- WHEN A test wraps
DependencyGraph.ofwith a counter and runs the explain selection over two items that each have an open dependency. - THEN The counter is 1.
Requirement: No graph without an open dependency
A selection SHALL build no dependency graph when no judged item has an open dependency.
Scenario: Stage items with closed dependencies
- WHEN A test wraps
DependencyGraph.ofwith a counter and runs the stage selection over items whose dependencies are closed. - THEN The counter is 0.
Requirement: Shortest cycle
The path search SHALL return a shortest cycle through the start item.
Scenario: Two cycles from one item
- WHEN A test calls
_path_backwith edges 1 to [2, 3], 2 to [1], 3 to [4] and 4 to [1], and start 1. - THEN The result is (1, 2, 1).
Requirement: Long ring
The path search SHALL find the cycle in a 20,000-item ring in under 5 seconds.
Scenario: Twenty-thousand-item ring
- WHEN A test calls
_path_backon a ring of 20,000 items and measures the elapsed time. - THEN The result is a cycle of 20,001 entries and the elapsed time is under 5 seconds.
Existing Tool Considered
The alternatives check in the issue body records not-applicable and names no tool. The change adopts no library for this internal performance fix; it edits the existing DependencyGraph and _path_back in src/devops_cli/roadmap/dependencies.py and src/devops_cli/roadmap/refine/refine.py. No replacement library is built, so no build-versus-tool token or elapsed-time cost applies.
Key questions
- How should stage, implement and explain reuse the dependency graph?: Build one lazy graph holder per selection. It calls
DependencyGraph.ofon the first cycle lookup and returns the same graph for later items. Pass the holder toopen_dependencyfor each judged item. (best practice) [sources: src/devops_cli/roadmap/dependencies.py:36, src/devops_cli/roadmap/dependencies.py:49, src/devops_cli/roadmap/stage/stage.py:774, src/devops_cli/roadmap/implement/implement.py:382]- Chosen: Lazy graph holder per selection. It keeps one build per selection and builds no graph when no item has an open dependency.
- Rejected: Eager graph per selection. It adds a 3.3 s build to a selection that has no open dependency.
- Rejected: Global memoization of DependencyGraph.of. The cache key is fragile and the cache keeps item graphs alive after the selection.
- Which algorithm should
_path_backuse to find the shortest cycle?: Use breadth-first search from the start item with a parent map. Reconstruct the cycle when a neighbor is the start item. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:1347, src/devops_cli/roadmap/refine/refine.py:1317]- Chosen: Breadth-first search with parent map. It returns a shortest cycle in O(V+E) time and stores one parent per node.
- Rejected: Current last-in-first-out search with path copies. It returns a longer cycle and copies the path at each step.
- Rejected: Floyd-Warshall. It computes all-pairs shortest paths in O(V^3) time and is too slow for a long ring.
- Where does the repeated graph build happen today?:
open_dependencycallsDependencyGraph.of(items).cycle_of(item.number)after it finds an open dependency. Stage and implement each callopen_dependencyfor each judged item. [sources: src/devops_cli/roadmap/dependencies.py:36, src/devops_cli/roadmap/dependencies.py:49, src/devops_cli/roadmap/stage/stage.py:774, src/devops_cli/roadmap/implement/implement.py:382]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 20, 2026
Each stage round wastes about 90 s of CPU and the cost grows with queue size, which is clear performance degradation.The regression commit 494de4f does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 with the label priority/p0-critical.Both work on dependency cycle detection in the roadmap, but #6449 adds the cycle check and this candidate fixes the per-item rebuild cost it introduced.devops-cli-service commentedon Nov 20, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 20, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 20, 2026
Released in v0.183.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.183.1
devops-cli-service commentedon Nov 20, 2026
Live since 2026-11-20 17:44 UTC