1

I have tried installing the RcppArmadillo package sparta (which is on CRAN) using three different methods.

  1. install.packages("sparta")
  2. devtools::install() (inside the package folder)
  3. devtools::build() and then install.package("path_to_build_file, repos = NULL, type = "source")

I then benchmarked a specific function, marg, from the sparta package and it turned out that installing with 1) and 3) yielded same results whereas using 2) the runtime of marg was more than twice as slow. I't seems to me that for all three methods, the same compiler, g++ = -std=gnu11, was used.

I have no clue why this is happening; any suggestions?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
mlindsk
  • 37
  • 5
  • 2
    Which operating system? Any other compiler options? Precompiled packages from CRAN (and source packages installed by `install.packages`) are compiled with the `-O2` option by default. It’s possible that `devtools::install` doesn’t do that (though it would be slightly surprising). – Konrad Rudolph Apr 22 '21 at 19:28
  • I'm on Ubuntu 20.04. I've specified `CXX_STD = CXX11` in the `Makevars` file which is just standard in `RcppArmadillo`. I've just confirmed that `devtools` indeed uses `-02`. – mlindsk Apr 22 '21 at 19:34
  • OK I've just noticed that method 1) and 3) uses the `ccache g++-10` which I have long forgotten that I specified in `.R/Makevars`. But should this make a big difference? And would this imply, that others might not experience as good a performance without setting up `ccache`? I'm quite new to these settings. – mlindsk Apr 22 '21 at 19:39
  • 2
    `ccache` speeds up the *build time*, it does not make the compiled binaries faster. Hwoever, if you’re using a different (and newer!) compiler, this might occasionally make a difference, since different compiler versions apply different performance optimisations. That said, all three methods should be using the same compiler, since that is also specified via `Makevars` somewhere. If they use different compilers, something’s messed up in the configuration. – Konrad Rudolph Apr 22 '21 at 19:41
  • Yes, that was also my understanding of `ccache`. I'll live with the uncertainty. Thanks for the pointers! – mlindsk Apr 22 '21 at 19:49

0 Answers0