-
Notifications
You must be signed in to change notification settings - Fork 17
Aeg/performance compute shortest paths parallel preparation #573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: aeg/performance_computeShortestPaths
Are you sure you want to change the base?
Aeg/performance compute shortest paths parallel preparation #573
Conversation
|
|
||
| // Given a graph (adjacency list), and vertices in topological order, return the shortest paths (and connections) | ||
| // from a given node to other nodes. | ||
| async computeShortestPaths( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a copy of the original code but declared as async. - only for quick & dirty testing
| // The shortest path from the start node to this vertex is a shortest path from the start node to a neighbor | ||
| // plus the weight of the edge connecting the neighbor to this vertex. | ||
| //neighs.forEach(([neighbor, weight]) => { | ||
| for (let idx = 0; idx < neighs.length; idx++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forEach replaced
Branch Performance Comparison
ConclusionUltimately, this change doesn’t have a significant impact.
We might need to explore real multithreading (Node.js worker threads could offer more power, Suggestion: Reject this approach for now. |
|
Thanks for trying :) |
Description
It would be highly beneficial to process this in parallel using 2 to 4 threads.
By applying Promise-based chunking and await logic, we could significantly reduce total runtime.
Especially for large network graphs, sequential pathfinding can become a major bottleneck.
Currently, pathfinding runs sequentially for each origin node and for big netzgrafik it takes quite a lot of time!
If we can make the
computeShortestPathsas well async then the following code should be executable in parallel. You can just add a new methodcomputeBatchShortestPathstoOriginDestinationService:In the
originDestinationData(): OriginDestination[] { ... }function (method) we have to replace:This code snipped
with
Issues
Checklist
documentation/