Building 3D Slicer is a very slow process. I’ve been experimenting with CCache to try speeding the process up and came up with this PR #5998. Here some background information for this idea.
What is CCache?
Ccache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again. The first time compilation has no performance benefit, but subsequent compilations will benefit from a performance increase.
CCache is well tested on Linux and MacOS. On Windows, it is not fully supported, though it could work (CCache support). The proposed Slicer integration only considers Unix systems (Linux/MacOS).
First results
These results have been obtained with:
- Intel(R) Xeon(R) CPU E3-1535M v6 @ 3.10GHz
- M.2 memory for the cache
How to use it? PR #5998
- Install ccache in your system (e.g.,
apt install ccache
in Ubuntu) - Configure Slicer with
-DSlicer_USE_CCACHE=ON
- Build a fresh Slicer so CCache can do the caching.
- Subsequent slicer builds (even from fresh repo clones) will use the cache (given that
-DSlicer_USE_CCACHE=ON
).
Discussion
Considering the initial results, I think this can be useful for developers who deal with multiple builds of Slicer (e.g., spawning multiple Slicer worktrees from the same repository to attend different issues). If used for the continuous integration process (e.g., nightly build of pre-cached containers that will be used for CI), this could potentially reduce the energy footprint of the project and lead to more agile CI. I think it would be also interesting to publish the pre-cached containers so they can be used as building environment with all the speedup benefits.
Please, feel free to give feedback on this idea.