FunWithR / MonteCarlo

An R package for simulation studies.
33 stars 15 forks source link

More more than 1 CPU doesn't work in Windows #3

Closed kylehamilton closed 6 years ago

kylehamilton commented 7 years ago

Hi, When I try to use more than one CPU in Windows everything slows down. It's still making the instances but they're just not doing anything. I've attached a screenshot to show what I'm talking about. For this, I just ran the t-test example.

mbm = microbenchmark( cpu1 = MonteCarlo(func=ttest, nrep=1000, param_list=param_list, ncpus=1), cpu2 = MonteCarlo(func=ttest, nrep=1000, param_list=param_list, ncpus=2), cpu3 = MonteCarlo(func=ttest, nrep=1000, param_list=param_list, ncpus=3), cpu4 = MonteCarlo(func=ttest, nrep=1000, param_list=param_list, ncpus=4), times=2 ) mbm

Unit: seconds expr min lq mean median uq max neval cld cpu1 2.42483 2.42483 2.507938 2.507938 2.591046 2.591046 2 a
cpu2 19.85909 19.85909 19.890274 19.890274 19.921458 19.921458 2 b
cpu3 27.96932 27.96932 29.825383 29.825383 31.681442 31.681442 2 c cpu4 35.92829 35.92829 36.198152 36.198152 36.468018 36.468018 2 d

image

FunWithR commented 7 years ago

Hi! Thank you very much for the feedback. The reason for this example getting slower is that the overhead from setting up the cluster is to big relative to the time saved by parallelized computation. The ttest() function is simply to fast for parallelization to make sense here. I admit that the example in the help file is a bit unfortunate. I will definitely update that. I also just posted a different example and a little discussion of the issue here. But as far as I can see at the moment the package works as intended here. Parallelization only makes sense if the computations are either slow or very many. Best regards!