Build Cache (Build Avoidance)

Build Cache reduces the build time by using a built-in caching option, which enables you to rebuild only objects that were modified, and not the whole code base. The performance improvement will be mainly manifested from the second execution onward, after the cache is populated in the first build execution. Therefore, this feature is not useful for Single-Use VMs.

To use build cache, you use a command line switch when running each build which both checks to see if there is anything useful in the cache, and stores the build you are running in the cache for future use. Using build cache requires additional storage space, which is allocated on the Initiator machine for the cache. We recommend allocating at least twice the size of the project output folder.

You define whether the cache can be shared across all users on an initiator machine ("shared"), a defined group of users ("group"), or for the current user ("user"). Groups of users are defined on your operating system. Whenever using the group option, the target group must be specified (e.g. group='devteam1').

In all cases, the cache can only be used on a single Incredibuild Initiator machine.

Configuring Build Cache Settings

The following commands can be used on the Initiator: 

  • Set the build cache size. By default, the size is 100GB, but you can modify it: 

    /opt/incredibuild/management/build_avoid_cache.sh <user|shared|group='groupname'> set_size <size in GB>

  • Return information about the location and size of your build cache:

    /opt/incredibuild/management/build_avoid_cache.sh <user|shared|group='groupname'> info

  • Clear the build cache:

    /opt/incredibuild/management/build_avoid_cache.sh <user|shared|group='groupname'> clear

Running Builds using Build Cache

When running builds, add the following command line switches to use build cache. By default, the --avoid commands are OFF. When they are used, they apply only to the current build.

  • --avoid-user activates build cache for the current user.

  • --avoid-shared activates build cache for everyone using on this initiator.

  • --avoid-group="groupname" activates build cache for all users in the specified group.

  • --avoid-basedir=<path> defines the base directory of your project. This information allows Incredibuild to utilize the caches from builds initiated from a different path.

For example:

ib_console --avoid-shared --avoid-basedir=/home/myuser/opencv/sources make -j 40