Replace the recursive SQL CTE in DetectCycles with Go-layer DFS using shared visited set. The previous implementation enumerated all paths through the dependency graph, causing exponential blowup with diamond patterns (multiple issues depending on the same target). Changes: - Add loadDependencyGraph() to load deps as adjacency list in one query - Implement DFS cycle detection with recStack for back-edge detection - Add normalizeCycle() for consistent cycle deduplication - Add DetectCycles-specific benchmarks (Linear, Dense, Tree graphs) - Use direct SQL INSERT in benchmarks to bypass AddDependency overhead Performance improvement on dense graph (500 nodes, 2500 edges): - Before: >120s timeout - After: 1.6ms Benchmarks: - DetectCycles_Linear_1000: 0.84ms (1000 nodes, 999 edges) - DetectCycles_Dense_500: 1.59ms (500 nodes, ~2500 edges) - DetectCycles_Tree_1000: 0.85ms (1000 nodes, 999 edges)
12 KiB
12 KiB