title: R's parallel Foreach slow to start with a high iterator value. What can be done?
body: <p>On a windows platform it seems that a high iterator value will stop foreach in its tracks.  For example </p>
  
  <pre><code>library(doParallel)
  library(foreach)
  cl&lt;-makeCluster(7) 
  registerDoParallel(cl)
  bayes_results&lt;-foreach (n=1:100) %dopar% {n}
  </code></pre>
  
  <p>This works just fine in a few seconds.</p>
  
  <p>However increasing the value to a few million stops foreach from working even after a several hour wait.</p>
  
  <pre><code>bayes_results&lt;-foreach (n=1:5000000) %dopar% {n}
  </code></pre>
  
  <p>What is the problem? How could it be solved? </p>
  
  <p>Thank you. </p>