drisso / SingleCellExperiment

Clone of the Bioconductor repository for the SingleCellExperiment package, see https://bioconductor.org/packages/devel/bioc/html/SingleCellExperiment.html for the official development version.
65 stars 18 forks source link

Slow load time of package #61

Closed alexvpickering closed 3 years ago

alexvpickering commented 3 years ago

The package is quite slow to load. This is only really an issue e.g. in a shinyproxy/docker served app where it substantially slows the initial time to render. For example (need to restart session):

system.time(library(SingleCellExperiment))
   user  system elapsed 
  3.349   0.116     3.467

A large part of this seems to be that SingleCellExperiment Imports DelayedArray:

system.time(library(DelayedArray))
  user  system elapsed 
  1.967   0.077   2.046 

And GenomicRanges:

system.time(library(GenomicRanges))
   user  system elapsed 
  1.416   0.063   1.479 

Is there anyway to delay loading these two packages until their used functions are called? Thanks for all the awesome package(s)!

LTLA commented 3 years ago

That's really a question for the SummarizedExperiment package maintainers, given that SE imports both anyway.

I strongly doubt that SE would consider not importing those two packages, though; they are fundamental to SE's operation. I believe R already uses a lazy-load mechanism for package code; I suspect that the extra time taken is due to some business with setting up the S4 tables/classes in the session. If so, any fix would have to occur deeper in the R language/interpreter itself.

On the whole... a 3 second delay isn't too bad. By comparison, iSEE has a 10-20 second delay for start up, given all the packages it has to haul in. In our deployments, we try to keep a single persistent session to avoid the cost of restarting a session.

alexvpickering commented 3 years ago

Thanks for the explanation.

I was looking for a way to avoid setting up a custom architecture as described by apsilon. In the meantime I found a way to at least start a container on login with shinyproxy.