parallelizing heterogenous tasks in R: foreach, doMC, doParallel
<p>Here's what's been puzzling me:</p>

<p>When you schedule a sequence of tasks that are homogenous in terms of content but heterogenous in terms of processing time (not known ex ante) using foreach, how exactly does foreach process these embarrassingly parallel tasks sequentially?</p>

<p>For instance, I registered 4 threads <code>registerDoMC(cores=4)</code> and I have 10 tasks and the 4th and the 5th each turned out to be longer than all others combine. Then the first batch is obviously the 1st, 2nd, 3rd and 4th. When the 1st, 2nd and 3rd are done, how exactly does foreach assign other tasks sequentially? Is that random (which seems so from my observation)? And what's a good practice to speed up if it turns out some tasks take way longer time to process?</p>

<p>I am sorry for not providing concrete examples since my actual projects/codes are much more involved...</p>

<p>Any experiences/guidance/pointers are very much appreciated!</p>