Skip to content

About Multicore: mclapply

3 messages · Prashantha Hebbar, Simon Urbanek, Martin Morgan

#
On Jan 16, 2012, at 9:02 AM, Prashantha Hebbar wrote:

            
multicore is designed for parallel *computing* which is not what you do. For serial tasks (like yours) it will be always slower, because it needs to a) spawn processes b) read the data (serially since you use the same location) c) serialize all the data and send it to the master process, d) unserialize and concatenate all the data in the master process to a list. If you run lapply it does only b) which is in your case not the slowest part. Using multicore makes only sense if you actually perform computations (or any parallel task).

Cheers,
Simon
#
On 01/16/2012 08:00 AM, Simon Urbanek wrote:
In case it's not clear, the system.time 'elapsed' time shows that 
mclapply *is* faster overall ('wall clock') -- I would have only .261 
seconds to go for coffee, compared to .419 with lapply.

As Simon suggests, a much more common paradigm is to put more work in to 
the function evaluated by lapply --, e.g., calculating qa() -- and then 
returning the result of the computation, typically a much smaller 
summary of the bigger data. Even in this case, your computer will need 
to have enough memory to hold all the fastq data in memory; for some 
purposes it will make more sense to use FastqSampler and FastqStreamer 
to iterate over your file.

Martin