Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mclapply user time larger than elapsed time

I am trying to use mclapply function of the parallel package in R. The function is assigning the values to sequence matrix by calculating log likelihood distance - a CPU-intensive operation.

The resulting system.time values are confusing:

> system.time(mclapply(worksample,function(x){p_seqi_modj(x,worksample[[1]],c(1:17))}))
   user  system elapsed 
 29.339   1.242  18.581 

I thought that elapsed means aggregated time (user+system). What does the above result mean in this case and to what time should I orient myself? My unparallelized version takes less in user time and much more in elapsed.

like image 485
zima Avatar asked Oct 22 '22 01:10

zima


1 Answers

The help page ?system.time says the value returned by the function is an object of class proc_time, and that we should consult ?proc.time. There we learn that user time is

cumulative sum of user and system times of any child processes

so your task has spent about 15s on each core (mclapply defaults to using 2 cores, see the mc.cores argument).

Actually, we see earlier in the help page that proc.time() returns five elements that separate the process and child times, and that the summary method used in printing collapses the user and system time into process + child times, so there is a bit more information available.

like image 175
Martin Morgan Avatar answered Oct 27 '22 19:10

Martin Morgan