Skip to content

Optimize MSD: Cache AnalysisContext across binary search probes #97

@networmix

Description

@networmix

Problem

The Maximum Supported Demand (MSD) workflow step was rebuilding the AnalysisContext for each binary search probe, causing significant overhead. Profiling showed _build_graph_core being called 15 times during
a single MSD run, taking 166s out of 309s total (54% of runtime).

Solution

Cache the AnalysisContext once at the start of MSD and reuse it for all alpha probes. Key changes:

  1. Create stable TrafficDemand objects with fixed IDs at MSD start
  2. Expand demands once to get augmentations (these don't change with alpha)
  3. Build AnalysisContext once with the augmentations
  4. Pre-build node/edge masks (no exclusions during MSD)
  5. Add _evaluate_alpha_cached() method that scales demand volumes without rebuilding infrastructure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions