Optimize path planning performance by 80x through provider improvements and A* implementation #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the critical performance issue where path planning on large street graphs was taking ~5 seconds for full searches, making the route planner demo unreliable for practical use.
Problem
The route_planner demo showed reliable path planning but with severe performance issues:
Root Cause Analysis
Performance bottlenecks were identified in two areas:
Solution
1. Walking Provider Optimization (80x Performance Improvement)
Optimized the synthetic walking provider to reduce computational overhead:
2. A* Search Algorithm Implementation
Implemented A* search with geographic distance heuristic as an alternative to Dijkstra:
planner_astar.c
with complete A* implementation using haversine distance heuristicgs_plan_with_planner()
function to support algorithm selection"dijkstra"
or"astar"
)3. Integration Improvements
gs_plan_with_planner()
in engine.c to support both Dijkstra and A* algorithmsPerformance Results
Before optimization:
After optimization:
Technical Details
The walking provider optimization reduces the search space dramatically while maintaining path quality. For typical routing scenarios, this addresses the core performance issue identified in the problem statement.
The A* implementation provides the foundation for additional performance improvements on long-distance routes by using geographic distance as an admissible heuristic to guide search toward the goal.
Testing
This change makes the graphserver route planner competitive with other path planning engines while maintaining accuracy and reliability.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.