Caching
The caching feature of FASTBuild allows compilation results from one build to be shared with another. If the inputs are the same, the compilation can be replaced with a simple file copy.
Caching requires:
- Compatible compilation settings
- Configuration of cache location
- Activation of caching
There are some performance implications of the cache that should be considered for optimal benefit.
- Performance - GCC/SNC/Clang
- Performance - MSVC
Some compilation settings are incompatible with caching. If any object cannot be safely cached, it will automatically be built without caching. A build can safely mix cacheable and uncacheable objects.
GCC/SNC/Clang
- No restrictions.
- Z7 Debug format must be used. (Debug information embedded within obj, written to pdb at link time.)
- /clr (Managed C) cannot be used.
The cache location can be a local or network path, specified either by:
- The .CachePath property of the Settings function
- The FASTBUILD_CACHE_PATH Environment Variable
On Windows UNC format paths are also supported.
The cache can be activated by the use of:
- The -cache[read|write] command line argument
- The FASTBUILD_CACHE_MODE Environment Variable ('r', 'w' or 'rw')
Be sure to read the Performance Implications section for use of the best options.
GCC/SNC/Clang
There are no adverse impacts on performance using the cache. The overhead is so low, it can be considered to be free in all situations.
MSVC
Using the cache adds some additional overhead which in some cases (such as zero cache hits) can make compile times slightly slower overall.
The overhead is generally quite minimal, and as little as a single cache hit can be enough to offset this cost.