Skip to content

Optimize: Update transitive closure algorythm.#920

Draft
hneiva wants to merge 1 commit intomainfrom
hneiva/transitive-closure
Draft

Optimize: Update transitive closure algorythm.#920
hneiva wants to merge 1 commit intomainfrom
hneiva/transitive-closure

Conversation

@hneiva
Copy link
Contributor

@hneiva hneiva commented Mar 13, 2026

The previous implementation scanned all edges on every iteration of a fixed-point loop, resulting in O(depth * edges) complexity. For deep dependency chains this is catastrophic - a 5000-node chain required 5000 full passes over all edges.

Replace with a standard Breadth-First Search using an adjacency list built once upfront, reducing complexity to O(vertices + edges). Benchmarks on large graphs show 22x-1333x speedups depending on graph shape, with identical results verified against the original algorithm.

The previous implementation scanned all edges on every iteration of a
fixed-point loop, resulting in O(depth * edges) complexity. For deep
dependency chains this is catastrophic - a 5000-node chain required
5000 full passes over all edges.

Replace with a standard Breadth-First Search using an adjacency list
built once upfront, reducing complexity to O(vertices + edges). Benchmarks
on large graphs show 22x-1333x speedups depending on graph shape, with
identical results verified against the original algorithm.
@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.01%. Comparing base (4aacfff) to head (86d36d8).

Files with missing lines Patch % Lines
src/taskgraph/graph.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #920      +/-   ##
==========================================
- Coverage   77.01%   77.01%   -0.01%     
==========================================
  Files         130      130              
  Lines       11796    11802       +6     
  Branches     1450     1454       +4     
==========================================
+ Hits         9085     9089       +4     
- Misses       2330     2331       +1     
- Partials      381      382       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant