kaskr / adcomp

AD computation with Template Model Builder (TMB)
Other
178 stars 81 forks source link

Reducing R package lib size further?... #369

Closed danielinteractive closed 1 year ago

danielinteractive commented 2 years ago

Hi @kaskr and all,

first of all thanks a lot for the TMB package, it is really useful and great!

Despite having developed code now with TMB for a couple of months, the whole compilation options are still a bit black box for me I feel. Right now we are preparing a package (https://github.com/openpharma/mmrm) for CRAN release. I am worried that the large lib size (still 73 Mb with latest version) will be a problem, as we already get a note for that.

I already trimmed the files down to just one cpp file which includes the TMB header. Anything else which we can do?

Any suggestions would be awesome, thanks!

Cheers Daniel

iantaylor-NOAA commented 2 years ago

Hi @danielinteractive, I don't have any ideas for the reducing things at the TMB end, but in the past I have removed the testthat element of a package to reduce the file size below CRAN's 5MB limit, and relied on running those tests on github. It's also possible that you would just have to give up on CRAN and continue to rely on github as the installation source. -Ian

kaskr commented 2 years ago

@danielinteractive The large shared objects are due to debugging information. For example, glmmTMB.so is currently 69M with a default build. By removing -g from the compile line it gets to 4.9M. The '-g' usually appears in R CMD config CXXFLAGS which one can modify (by using a custom Makevars file). The size can be reduced even more by removing symbol information. By adding -Wl,-s to the linker (see https://github.com/kaskr/adcomp/wiki/FAQ) it gets to 3.7M. Unfortunately, none of these solutions are allowed by CRAN.

There might be some more info in this thread: https://stat.ethz.ch/pipermail/r-devel/2016-October/073271.html

danielinteractive commented 2 years ago

Thanks a lot @iantaylor-NOAA and @kaskr for your helpful replies! Luckily and surprisingly at the same time this issue did not come up on CRAN pretest runs ... I hope that it is not an issue. (I wonder if CRAN installs packages with the --strip option and therefore reduces size automatically?

potoole7 commented 2 years ago

@danielinteractive I came across this Makevars https://github.com/jkbest2/spatq/blob/aef9ee5f8eca811ee11c484ee803ed7485775195/src/Makevars, which uses a solution by Dirk Eddelbuettel (link in file) that seems to help (by magic!).

danielinteractive commented 2 years ago

@paddy7wb yeah I have seen that, but unfortunately it is not allowed on CRAN, it is explicitly mentioned in the Writing R extensions.

danielinteractive commented 1 year ago

I think we can close this.