bplapply slow to decide number of cores
1
0
Entering edit mode
@charles-plessy-7857
Last seen 6 months ago
Japan

I am surprised that bplapply() takes a few seconds to detect the number of available cores, while multicoreWorkers() or MulticoreParam() are fast when they run by themselves:

> system.time(BiocParallel::bplapply(1:1e2 , function(x) order(rnorm(n=1e3)), BPPARAM = MulticoreParam()))
   user  system elapsed
  0.060   0.180   4.033

Multicore setup is fast if number of cores is fixed: 

> system.time(BiocParallel::bplapply(1:1e2 , function(x) order(rnorm(n=1e3)), BPPARAM = MulticoreParam(1)))
   user  system elapsed
  0.036   0.004   0.042

Slow if the choice is delegated to multicoreWorkers():

> system.time(BiocParallel::bplapply(1:1e2 , function(x) order(rnorm(n=1e3)), BPPARAM = MulticoreParam(multicoreWorkers())))
   user  system elapsed
  0.056   0.140   4.034

But by itself, multicoreWorkers() is fast!

> system.time(multicoreWorkers())
   user  system elapsed
  0.000   0.032   0.037

I am running BiocParallel 1.10.0.

biocparallel • 1.2k views
ADD COMMENT
2
Entering edit mode
@martin-morgan-1513
Last seen 3 days ago
United States

The 'fast' version is actually because you've set the number of cores to 1; BIocParallel cheats in this circumstance and just does lapply locally. For the other versions the cost is creating the forked processes and sending data to and from the workers. For me the time is <.5s so I'm surprised at how slow your computations seem to be. You could separate out the setup costs (and amortize over uses in a script, for instance, with

param = MulticoreParam()
bpstart(param)

and then separately

bplapply(seq_len(100), function(x) order(rnorm(n=1e3)), BPPARAM=param

with a final clean-up

bpstop(param)

It would be helpful to know your sessionInfo()

ADD COMMENT
0
Entering edit mode

Indeed the speed has a lot to do with the session. I tried the bplapply command in a fresh session and it took 0.6 s.  Then I loaded GenomicRanges and it took 1.4 s, then I added SummarizedExperimentMultiAssayExperiment and rtracklayer,  and the elapsed time rose to 2.0, 2.3 and 2.8 s respectively !

ADD REPLY

Login before adding your answer.

Traffic: 671 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6