Skip to content

perf: run GetGraph and GetCircularDependencies in parallel to halve API latency #52

@claude

Description

@claude

Problem

In cmd/run.go:248–271 (fetchGraphWithCircularDeps) and internal/api/client.go:414–467, GetGraph and GetCircularDependencies are called sequentially:

graph, err := client.GetGraph(ctx, projectName, repoZip)         // uploads zip, polls ~10-15 min
circDeps, err := client.GetCircularDependencies(ctx, projectName, repoZip) // uploads zip again, polls again

The two calls are completely independent — neither depends on the other's result. Running them back-to-back means:

  • The repo zip (up to 10 MB) is uploaded twice over the network.
  • Total wall-clock time is time(GetGraph) + time(GetCircularDeps) instead of max(time(GetGraph), time(GetCircularDeps)).

Fix

Run both calls concurrently using goroutines and a sync.WaitGroup (or errgroup). Collect results from both, then merge circDeps into graph.Stats.CircularDependencyCycles exactly as today.

This would roughly halve the total time spent waiting for the API on a cache miss.

Relevant files:

  • cmd/run.go:248–271fetchGraphWithCircularDeps
  • internal/api/client.go:414–467GetGraph / GetCircularDependencies

@claude please implement this

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions