Small things that I don't to want to forget...
Threads.@spawn should be preferred to @async !
Actually, the doc STRONGLY RECOMMENDS to do so. I underestimated its influence on performance: when I used @async, the script that ran fast otherwise became soooooo slow (that I looked for a bug that did not exist)!!!
The mechanism involves task migration (according to the doc).
There should be either multiple threads or sleep time to prevent other tasks from hanging!
When I schedule a task that is always busy [e.g. loops without sleep()] by Threads.@spawn, one thread is occupied by the task.
Hence, even though the task is 'spawned', other tasks cannot move forward!
Performance with EnsembleProblem: solve(EnsembleProblem, ...) takes an optional keyword argument pmap_batch_size !
When calculation of a single trajectory is costly (which is usually the case for me), I should set pmap_batch_size=1 !
Otherwise (by default), trajectories are grouped into at most 100 batches.