I have an algorithm that's very easy to run in par...
# coroutines
m
I have an algorithm that's very easy to run in parallel (think finding a best path), extremely CPU intensive, and would actually benefit from running only n branches at once for n CPU threads (once a solution is found, branches can be culled eagerly, so exploring a solution fully quicker is better than exploring more than n at once). Is there a dispatcher that would block new coroutines until some are finished, in such a way that only n would run for n CPU threads? Or is this too high level for dispatchers and I have to write my own orchestration logic?
m
Ha nice, didn't find that one somehow - thanks!
n
Dispatchers.Default
is max(cpuCount, 2)
m
It's surprising, I get noticably different results by limiting
Dispatchers.Default
to
Runtime.getRuntime().availableProcessors()
r
I'm guessing because using
availableProcessors()
ignores hyperthreading
m
It returns the number of logical processors, so in my case 8 (4*2), which is what I expected, and from my observations
Dispatchers.Default
was able to leverage all the logical processors as well