Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library load time is very long #12

Open
nsheff opened this issue Oct 11, 2024 · 3 comments
Open

library load time is very long #12

nsheff opened this issue Oct 11, 2024 · 3 comments

Comments

@nsheff
Copy link

nsheff commented Oct 11, 2024

The library function call is very slow. Here are some benchmarks:

Rscript -e "microbenchmark::microbenchmark(library(devtools), times=1, unit='seconds')"
Unit: seconds
              expr       min        lq      mean    median        uq       max
 library(devtools) 0.7143343 0.7143343 0.7143343 0.7143343 0.7143343 0.7143343
 neval
     1

Rscript -e "microbenchmark::microbenchmark(library(dplyr), times=1, unit='seconds')"
Unit: seconds
           expr       min        lq      mean    median        uq       max
 library(dplyr) 0.3258483 0.3258483 0.3258483 0.3258483 0.3258483 0.3258483
 neval
     1


databio/lab|~$ Rscript -e "microbenchmark::microbenchmark(library(bedbaser), times=1, unit='seconds')"
Unit: seconds
              expr      min       lq     mean   median       uq      max neval
 library(bedbaser) 8.686374 8.686374 8.686374 8.686374 8.686374 8.686374     1


databio/lab|~$ Rscript -e "microbenchmark::microbenchmark(library(LOLA), times=1, unit='seconds')"
Unit: seconds
          expr      min       lq     mean   median       uq      max neval
 library(LOLA) 2.352586 2.352586 2.352586 2.352586 2.352586 2.352586     1

devtools: 0.71 seconds
dplyr: 0.33 seconds
bedbaser: 8.7 seconds
LOLA: 2.4 seconds

For a package that is just a simple API interface, does this seem longer than should be necessary to load a package?

@jwokaty
Copy link
Collaborator

jwokaty commented Dec 3, 2024

This seemed to be due to the way I had been loading functions, especially rtracklayer. This is what I get with 0.99.11.

~/R-devel/bin/Rscript -e "microbenchmark::microbenchmark(library(bedbaser), times=1, unit='seconds')"                                                         
Unit: seconds
              expr      min       lq     mean   median       uq      max neval
 library(bedbaser) 0.405445 0.405445 0.405445 0.405445 0.405445 0.405445     1

@nsheff
Copy link
Author

nsheff commented Dec 3, 2024

That looks much better!

Just out of curiosity -- what exactly did you need to do differently? So I can make sure I'm doing it right in my other packages...

@jwokaty
Copy link
Collaborator

jwokaty commented Dec 3, 2024

I was using @importFrom package function in all my functions, which I changed to package::function within my functions. The previous way seemed to create a lot of initial overhead, especially with rtracklayer, which has a lot of dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants