steve-the-bayesian / BOOM

A C++ library for Bayesian modeling, mainly through Markov chain Monte Carlo, but with a few other methods supported. BOOM = "Bayesian Object Oriented Modeling". It is also the sound your computer makes when it crashes.
GNU Lesser General Public License v2.1
36 stars 15 forks source link

Boom package takes over 600 mb after installing with R #58

Closed santhisenan closed 3 years ago

santhisenan commented 3 years ago

I am trying to install BSTS R package on a docker container. Boom package is installed in usr/local/lib/R/site-library/Boom. However, the size of the file libboom.a is over 600 mb.

Is there a way to reduce the file size for this file as I am trying to make my container leaner.

image

To reproduce this, build using this Dockerfile:

FROM rocker/r-base:4.1.0 AS compile-image
RUN apt-get update \
    && mkdir $HOME/.R
COPY Makevars .R/

RUN wget "https://cran.r-project.org/src/contrib/Boom_0.9.7.tar.gz"
RUN R CMD INSTALL --strip --clean "Boom_0.9.7.tar.gz"

I added the --strip argument as it is suggested in this blog post.

This is the Makevars file:

SHLIB_CXXLDFLAGS = -Wl,-S -shared
SHLIB_CXX11LDFLAGS = -Wl,-S -shared
SHLIB_CXX14LDFLAGS = -Wl,-S -shared
SHLIB_FCLDFLAGS = -Wl,-S -shared
SHLIB_LDFLAGS = -Wl,-S -shared

# strip debug symbols for smaller Linux binaries
strippedLib: $(SHLIB)
    if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; \
        then /usr/bin/strip --strip-debug $(SHLIB); fi
.phony: strippedLib
steve-the-bayesian commented 3 years ago

If you manually strip the library using the bash "strip" utility it will be significantly smaller.

On Fri, Aug 6, 2021, 1:44 AM Santhisenan A @.***> wrote:

I am trying to install BSTS R package on a docker container. Boom package is installed in usr/local/lib/R/site-library/Boom. However, the size of the file libboom.a is over 600 mb.

Is there a way to reduce the file size for this file as I am trying to make my container leaner.

[image: image] https://user-images.githubusercontent.com/14852343/128482511-2e00b5af-ac27-42a0-9865-85e4bc0f2607.png

To reproduce this, build using this Dockerfile:

FROM rocker/r-base:4.1.0 AS compile-image RUN apt-get update \ && mkdir $HOME/.R COPY Makevars .R/

RUN wget "https://cran.r-project.org/src/contrib/Boom_0.9.7.tar.gz" RUN R CMD INSTALL --strip --clean "Boom_0.9.7.tar.gz"

I added the --strip argument as it is suggested in this blog post http://dirk.eddelbuettel.com/blog/2019/03/27/.

This is the Makevars file:

SHLIB_CXXLDFLAGS = -Wl,-S -sharedSHLIB_CXX11LDFLAGS = -Wl,-S -sharedSHLIB_CXX14LDFLAGS = -Wl,-S -sharedSHLIB_FCLDFLAGS = -Wl,-S -sharedSHLIB_LDFLAGS = -Wl,-S -shared

strip debug symbols for smaller Linux binariesstrippedLib: $(SHLIB)

if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; \
    then /usr/bin/strip --strip-debug $(SHLIB); fi.phony: strippedLib

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/steve-the-bayesian/BOOM/issues/58, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMVDVPOZFA5GRBAWZLGTFLT3OOGZANCNFSM5BVPBQYQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

santhisenan commented 3 years ago

Thank you Steve for your reply.

I ran strip --strip-unneeded usr/local/lib/R/site-library/Boom/lib/libboom.a after installing the library. The file size reduced to just 30mb. Hope it does not affect the BSTS package.

image