[R] mcapply not using more than 1 core
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Aug 28 08:14:44 CEST 2013
On 28/08/2013 06:54, joe meiring wrote:
> This does speed up on an OsX install, so something must be wacky with the
> linux install. Any ideas as to what would cause this?
It does on a Linux platform ('install' has nothing to do with this):
> system.time(x <- lapply(test,function(x) loess.smooth(x,x)))
user system elapsed
4.095 0.036 4.140
> system.time(x <- mclapply(test,function(x) loess.smooth(x,x),
mc.cores=24))
user system elapsed
8.125 0.639 0.563
What is odd is that no CPU time is being recorded in the original posting.
That is about what I would expect: there is an overhead in forking 24
processes and this example is too small to be realistic.
>
> On Tuesday, August 27, 2013 4:19:31 PM UTC-7, joe meiring wrote:
>>
>> I can't seem to get mclapply to use more than a single core. I have a 64
>> core server running Linux.
>>
>> Fore example:
>>
>> library(parallel)
>>
>> test <- lapply(1:100,function(x) rnorm(10000))
>> system.time(x <- lapply(test,function(x) loess.smooth(x,x)))
>> system.time(x <- mclapply(test,function(x) loess.smooth(x,x),
>> mc.cores=32))
>>
>> gives me:
>>
>> user system elapsed
>> 0.000 0.000 7.441
>> user system elapsed
>> 0.000 0.000 8.868
>>
>> i.e. mclapply is taking longer than lapply(). What is going wrong here?
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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.
>>
>>
>>
>> ______________________________________________
>> R-help at 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.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list