Today I just discovered ccache
https://ccache.samba.org/and would recommend it to anyone who tracks the git repository (including Jenkins, if we can get ccache working on 64-bit Windows). Essentially, it caches compilations so that they can be reused if the file doesn't change (even if you do make clean-all beforehand).
After installing and configuring, run it once serially so that it can cache Stan's C++ files
goodrich@CYBERPOWERPC:/opt/stan$ make clean-all && time make CC="ccache g++" O=3 test-models > /tmp/g++_caching.log
...
real 93m52.243s
user 87m29.122s
sys 4m58.650s
Now files are cached:
goodrich@CYBERPOWERPC:/opt/stan$ ccache -s
cache directory /home/goodrich/.ccache
cache hit (direct) 0
cache hit (preprocessed) 0
cache miss 158
called for link 147
unsupported compiler option 11
files in cache 464
cache size 163.3 Mbytes
max cache size 1.0 Gbytes
Now, you can henceforth do it in parallel much faster and with much more limited RAM spikes
goodrich@CYBERPOWERPC:/opt/stan$ make clean-all && time make CC="ccache g++" O=3 -j8 test-models > /tmp/g++_cached.log
...
real 11m48.354s
user 58m20.964s
sys 2m42.890s
goodrich@CYBERPOWERPC:/opt/stan$ ccache -s
cache directory /home/goodrich/.ccache
cache hit (direct) 145
cache hit (preprocessed) 8
cache miss 163
called for link 294
unsupported compiler option 417
files in cache 456
cache size 159.2 Mbytes
max cache size 1.0 Gbytes
We can save a couple more minutes once I make an unrelated tweak to the lsat test. But it already takes only half the time as a parallel run without caching
goodrich@CYBERPOWERPC:/opt/stan$ make clean-all && time make CC=g++ O=3 -j8 test-models > /tmp/g++_nocached.log
...
real 23m3.460s
user 140m26.479s
sys 4m8.016s
I don't think ccache works properly with clang++ yet, but clang++ is already decently fast on test-models.
Ben