Parallelize routing#1292
Conversation
Co-authored-by: aider (openrouter/anthropic/claude-3.5-sonnet) <aider@aider.chat>
|
Thanks for submitting a PR! This fixes #1218. |
|
I've made a couple nitpicking adjustments so that the parallelization code looks similar to other places in the codebase and I've been testing this in a relevant setup: remote The problem arise if we stretch the test to many more routes: for an instance with 400 routes, the parallelization has somehow throttled the OSRM server and I'm ending up with a We should probably limit parallelization in a configurable way, maybe re-using the Note: the same limitation theoretically applies to the parallelized matrix computations, but the number of parallel requests is much lower as it's bounded by the number of profiles in use. |
|
Added a limit to the parallelization using a semaphore. This starts all the threads, but has all except Tried this with vroom-docker to confirm it reacts to the |
jcoupey
left a comment
There was a problem hiding this comment.
The use of counting_semaphore looks like a very neat solution, thanks for the update!
Out of curiosity, what is the reason for choosing a template value of 128?
|
I've been running further tests with a remote osrm server and a low bandwidth. Already having a few threads (4 or 8) makes a huge difference: the overall routing time is more than 6x faster. Then for e.g. 32 and 64 threads, the overall routing time is slightly higher so it looks like the threads boilerplate exceeds the benefit. Maybe that would hint toward using a max number of 32, which would also be in line with the rest of the parallelization strategy. @michael-struwe-mischok do you have other input? what do you think? |
|
From how I understand the mentions of The 128 was just a guess on how many parallel requests might be a good idea. We could also choose a higher maximum, e.g. 512. Someone might configure their OSRM to be powerful enough for this many requests / their network conditions may make it appropriate. (I assume the overhead of a too-high maximum is pretty low) Maybe we shouldn't use Example scenario:
However in an ideal setup, probably you should run OSRM and VROOM on the same machine to minimize the network time. In that case, |
|
You're right that this should ideally be configured differently, but it's kind of very routing specific so I don't really feel like having another dedicated parameter for that. As your example shows, this is highly dependent on the routing deployment (not only If using On the other hand, users that have a routing setup allowing higher request rates can increase the default value (we could even make the |
|
👍 In general I don't want to block this with details so feel free to just do sth that seems appropriate :-) I think
|
|
Good point about taking the min. I've introduced a I kept the |
|
For the record, I've also run some quick tests using libosrm and noticed the same magnitude in routing time reduction. |
Issue
#1291
Tasks
CHANGELOG.md(remove if irrelevant)