title: Issue with doParallel and foreach. I can register cores, but they don't seem to run
body: <p>I have a large data set (about 40 million rows x 4 columns) and I want to perform a Fisher test on the data in each row. </p>
  
  <p>An example of the data looks like this: </p>
  
  <pre><code>refAppleBase altAppleBase refHawBase altHawBase
  1          115            1         94          0
  2          117            4         93          1
  3          125            4         94          1
  4          107           26         89         12
  5           87           53         66         38
  6           68           58         64         32
  </code></pre>
  
  <p>I have written the following script that essentially takes each row, converts into a matrix so it can run on the base <code>fisher.test()</code> function in R, and then spits out the odds ratio and p-value. </p>
  
  <pre><code>fisher.odds.pval &lt;- function(table){ 
  fisher &lt;- fisher.test(matrix(unlist(table), nrow=2, ncol=2))
  p.val &lt;- fisher$p.value
  odds &lt;- unname(fisher$estimate)
  return(cbind(odds, p.val))
  }
  </code></pre>
  
  <p>Now, obviously this a little clunky and I want to run it across 40 million rows, so to save time, I wrote the following script, using the <code>foreach</code> and <code>doParallel</code> packages to parallelize this across multiple cores. </p>
  
  <pre><code>library(doParallel)
  library(foreach)
  
  cl &lt;- makeCluster(10)
  registerDoParallel(cl)
  results &lt;- foreach(i=1:nrow(dat)) %dopar% {
    fisher.odds.pval(table=dat[i,])
  }
  stopCluster(cl)
  </code></pre>
  
  <p>I have used <code>doParallel</code>in the past to great success. However, when running the above script, I can see the cores "wake up" and load in data, but then immediately go to sleep. Then it seems that just one core is doing all of the computing. Here is a screen grab of <code>top</code>, when the above code is running. </p>
  
  <p><a href="https://i.stack.imgur.com/ChQQt.png" rel="nofollow noreferrer">top screen grab</a></p>
  
  <p>Note: When I run the above script on a smaller dataset using <code>%do%</code> instead of <code>%dopar%</code> it works, so I suspect there something fishy going on between the way <code>foreach</code> and <code>doParallel</code> are communicating? But really lost here right now. Any thought greatly appreciated. </p>