-
Notifications
You must be signed in to change notification settings - Fork 604
COMP: speed up Linux compilation by using precompiled headers #7908
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
base: main
Are you sure you want to change the base?
COMP: speed up Linux compilation by using precompiled headers #7908
Conversation
321bcea
to
6ce6b1d
Compare
This branch was only tested on Linux Ubuntu 22.04 LTS. It is quite easy to speed up compilation in Libs and Base thanks to vtk, itk and qt precompiled headers. Build test done: - DBUILD_TESTING=OFF cmake option - with 12 jobs for the 12 cores of my intel i7 CPU - commands: cd build-dir/Slicer-Build/Libs && make clean && make -j12 cd build-dir/Slicer-Build/Base && make clean && make -j12 Build times: Libs: without precompiled headers: 44m 28s with precompiled headers: 18m9s Base : without precompiled headers: 10m 35s with precompiled headers: 2m 54s This branch is simply a proposal to show the benefits of precompiled headers, do not hesitate to ask questions and propose better code. Precompiled headers are harder to use in Modules because the target library and the source binary must use the same compilation flags (for instance *_EXPORTS flag must be the same)
6ce6b1d
to
8f6b1dd
Compare
@lassoan @jcfr @RafaelPalomar What do you think about this pull request ? |
Thank you @achataigner, this looks like a potentially significant speedup! My computer builds Slicer from scratch (including all dependencies) in about 30 minutes with gcc on Linux, but MSVC on Windows takes hours. So, I'm curious to see how much improvement can be achieved on Windows. I've started a build. I'll let you know when it is done. |
I've built Slicer from scratch on Windows in release mode and got the following results: Slicer main:
With precompiled headers in this pull request:
(I've also tried to speed up the build process on Windows by doing parallel build: Based on these results, I'm not sure if this is worth the trouble. But maybe just the proposed changes are ineffective on Windows. |
This branch only speeds up Libs and Base build so I am not surprised by your results. Again, this branch is a draft, we could use precompiled header in other libs than Libs and Base and get real improvements on the whole build. Moreover precompiled header is quite easy to use in CMakeLists.txt, it does not really complexify current CMake code. @jcfr @RafaelPalomar @pieper What are your opinions ? |
Has anyone tried profiling the build, something like this suggestion? Personally I find SimpleITK, Testing, and CLIs to be the slowest parts of the build, but I never find it enough of a bottleneck to invest time in addressing. |
I just started a Ninja build. |
COMP: Speed up Linux compilation by using precompiled headers
This branch was only tested on Linux Ubuntu 22.04 LTS.
It is quite easy to speed up compilation in Libs and Base thanks to
vtk, itk and qt precompiled headers.
Build test done:
cd build-dir/Slicer-Build/Libs && make clean && make -j12
cd build-dir/Slicer-Build/Base && make clean && make -j12
Build times:
Libs:
without precompiled headers: 44m 28s
with precompiled headers: 18m9s
Base :
without precompiled headers: 10m 35s
with precompiled headers: 2m 54s
This branch is simply a proposal to show the benefits of precompiled headers,
do not hesitate to ask questions and propose better code.
Precompiled headers are harder to use in Modules because the target library
and the source binary must use the same compilation flags (for instance *_EXPORTS flag must be the same)