I'm noticing a huge performance hit when using foreach with doSNOW. Any ideas on why the parallel loop runs ~8 times slower than the same foreach run sequentially? > require(doSNOW) Loading required package: doSNOW Loading required package: foreach foreach: simple, scalable parallel programming from Revolution Analytics Use Revolution R for scalability, fault tolerance and more. http://www.revolutionanalytics.com Loading required package: iterators Loading required package: snow > cl = makeSOCKcluster(rep("localhost",3)) > registerDoSNOW(cl) > > system.time(( + x = foreach(i=seq(1,5000)) %dopar% { + arima.sim(n = 250, list(ar=c(0.8897, -0.4858), ma=c(-0.2279, 0.2488)), + rand.gen = function(n, ...) sqrt(0.1796) * rt(n, df = 5)) + } + )) user system elapsed 4.46 0.22 50.27 > > system.time(( + y= foreach(i=seq(1,5000)) %do% { + arima.sim(n = 250, list(ar=c(0.8897, -0.4858), ma=c(-0.2279, 0.2488)), + rand.gen = function(n, ...) sqrt(0.1796) * rt(n, df = 5)) + } + )) user system elapsed 6.25 0.01 6.27 > system.time(( + for (i in seq(1,5000)) { + x = arima.sim(n = 250, list(ar=c(0.8897, -0.4858), ma=c(-0.2279, 0.2488)), + rand.gen = function(n, ...) sqrt(0.1796) * rt(n, df = 5)) + } + )) user system elapsed 2.76 0.00 2.76
Dominic J. Pazzula +-+-+-+-+-+-+-+-+-+-+- domp...@yahoo.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.