title: Why the parallelization of the following code takes too much to run?
body: <p>The following piece of code is supposed to be very easy to run. In sequential mode it is executed in less than a second. However when I make it parallel it seemingly takes forever to run. If I set the vector lengths to 100 the code runs fine so I don't think it's a structural issue.</p>
  
  <pre><code>  library(foreach)
      library(doParallel)
      cl &lt;- makeCluster(4)
      registerDoParallel(cl)
      bvec &lt;-as.vector(1:1e3)
      avec &lt;-as.vector(1:1e3)
      sim= function(x,y) 10*x+y
      system.time(x &lt;-
         foreach(b=bvec, .combine='cbind') %:%
         foreach(a=avec, .combine='c') %dopar% {
           sim(a, b)
           })
  </code></pre>
  
  <p>What is the catch? 
  Appreciated.</p>