Skip to content

⚡ Bolt: Optimize BuildCandidateRoutes LINQ allocation overhead#265

Open
google-labs-jules[bot] wants to merge 1 commit into
masterfrom
perf-optimize-build-candidate-routes-17572096243513606914
Open

⚡ Bolt: Optimize BuildCandidateRoutes LINQ allocation overhead#265
google-labs-jules[bot] wants to merge 1 commit into
masterfrom
perf-optimize-build-candidate-routes-17572096243513606914

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

💡 What: Materialized activeProducers and activeConsumers lists outside of the nested foreach loops in the BuildCandidateRoutes methods of TemporalNetworkSimulationEngine.cs and MixedRouting.cs.

🎯 Why: The original implementation was re-evaluating the LINQ queries (.Where(...), .Select(...)) on context.Demand and context.Supply for every single iteration of the outer producer loops. This caused severe O(P * C) redundant enumerator allocations and CPU evaluations during intensive capacity bidding phases, significantly slowing down large simulations.

📊 Impact: Reduces redundant LINQ enumerations and object allocations from O(P * C) to O(P + C) for every call to BuildCandidateRoutes. This dramatically improves throughput during global routing capacity bidding (which runs repeatedly in a while (true) loop).

🔬 Measurement: The performance improvement can be measured by running any simulation benchmark involving complex networks with many producing and consuming nodes. Run the application, load a complex model with mixed routing, and observe reduced CPU utilization and garbage collection pauses during the routing passes. The test suite ran cleanly (129/129 passed).


PR created automatically by Jules for task 17572096243513606914 started by @wnj00524

@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

0 participants