Skip to content

foreach performance

1 message · Dom Pazzula

#
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?
?
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
+ 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
+ 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
+ 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
+-+-+-+-+-+-+-+-+-+-+-
dompazz at yahoo.com