-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Built with LTO #238
Comments
@aadler Is it possible to build an R package like rstanarm on Windows with LTO? I am not expecting it to execute any faster but hoping the build process takes fewer resources on win-builder. |
@bgoodri Hi. LTO as it is implemented in GCC 4.9.3 which underlies the current version of Rtools is either incomplete or incorrect. When I tried to build even base R with LTO, it interfered with various packages like dplyr so I had to install some from source and some from binary. Even when installing from source, I had to change the Makevars and install some packages with LTO and some without, which then requires ffat-lto-objects which increases file size. The one time I tried to build R with a custom-built version of GCC 7.1.0, if I recall correctly, I used LTO and it worked better, but I don't remember clearly. Therefore, after months of trying, I stopped recommending using LTO for building on Windows, and would continue to do so until Rtools is moved to GCC 7 at least. For that, @jeroen (aka @ropensci) is the new keeper of Rtools. All bribes should be sent his way ;) |
I considering if we should enable LTO for the new toolchain. Can you give me an example that shows a case for how this would be useful to support? |
@jeroen It would be great if LTO worked with the Windows C++ toolchain. Currently, installing rstanarm on CRAN under r-release-windows-ix86+x86_64 takes 2135 seconds and the shared object consumes 17.3Mb of disk space. On Linux with g++-7, installation time with LTO is 75% of the time without LTO and disk space consumed with LTO is also 75% of the disk space without LTO. Additionally, although it is not a problem for CRAN, installing rstanarm in parallel with 8 cores on Linux consumes almost 16 GB of RAM. With LTO, I can get the peak RAM spike down to 13.5 GB. Someone else has found ( http://discourse.mc-stan.org/t/thinlto-standard-benchmarks/3673?u=bgoodri ) that the execution time for a bunch of Stan models is around 5% less when compiled with LTO (under clang). |
@jeroen I'm not sure what you mean by enable. The toolchain, at least as of 3.4, has LTO enabled, but its implementation in GCC 4.9.3 was incomplete and often not worth it, at least in my many experiments. When the toolchain for windows will be based on GCC 7+, then it should certainly be continued to be built with LTO enabled. |
@jeroen @aadler Is there a known trick to compiling a DLL using LTO with R-testing for Windows? In my ~/.R/Makevars, I have
But when I try to compile a Stan program (e.g. with
although the DLL does compile and load. However, when I try to execute it, R crashes with a corrupted backtrace (under
Do either of you have any idea what I am doing wrong? |
No, I gave up a while ago. I should try again one of these days with @jeroen latest and greatest Rtools4. Sorry. |
Summary:
After / during the feature/2.17 is merged, we need to figure out how to build rstanarm with LTO whenever possible.
Description:
Adding
-flto=8
to the ~/.R/Makevars reduces the compile time to about 30 seconds per Stan program (in parallel) and about 90 seconds to link.R Version:
3.4.x
Operating System:
Debian
The text was updated successfully, but these errors were encountered: