Optimizing the Build Performance for Visual Studio

Optimizing the Build Performance for Visual Studio

In certain cases, it may be possible to further improve build speed of MS Visual Studio projects by fine-tuning certain aspects of either IncrediBuild's configuration or the project settings. This section lists common causes for not obtaining optimal results using IncrediBuild. Different environments and projects respond differently to a change in configuration, so the best way to go is to try out the different suggestions and see the effect each has on build time.

For additional important performance-related tips see this section.

Tips in This Page:

Using the "IncrediBuild_AllowOverlap" Directive

The IncrediBuild_AllowOverlap directive may speed up builds in cases where dependencies between projects are defined in a solution/workspace, and project-level custom build steps or build events (post-build, pre-link, etc.) are used in these projects.
Take the following case: Project B is a sub-project of project A, and contains a project-level custom build step, a pre-link step, or a post-build step. Consequently, project A will not start to compile until project B's step has been performed. While this ensures that projects are successfully built as long as dependencies have correctly been defined, it may also unjustifiably slow down the build if project B's step is not required by project A's source files. In this case, using the IncrediBuild_AllowOverlap directive will instruct IncrediBuild not to postpone project A's compilation.

Using the IncrediBuild_AllowOverlap directive is explained in full detail in this section.

Enabling IncrediLink

Note:

The IncrediLink option can speed up incremental links from minutes to a few seconds. See here for more details.

Distributing Custom Build Steps, Custom Build Rules, and Build Events

If custom build steps, files running custom build rules, or build events (pre-build, pre-link, and post-build) take up a large portion of your build time, it may be a good idea to consider using the optional IncrediBuild Interfaces extension package to distribute execution of these steps, in addition to compilation and MIDL steps. For more information on how to distribute these steps, see this section.

Optimizing Project Settings

The following suggestions for changes in the project settings can help improve build times, specifically when using IncrediBuild:

Limiting the number of PDB files

Note:

To achieve its distribution, IncrediBuild creates a separate PDB file for each Agent running at any given time. This means that, unlike standard MSVC builds, multiple PDB files are created in intermediate folders, which can potentially slow down the link phase. The Agent Settings dialog Visual Studio Builds->Advanced page allows you to limit the number of PDB files that are created in each project's intermediate folder. While this may speed up linking, it also means that you are limiting the number of Agents allowed to concurrently compile files from the same project. Therefore, it is generally advised to use this option only if your builds typically include files from a relatively large number of projects.

Optimizing Project Build Order

Note:

If necessary, you can specify Project build priorities through the Solution Settings dialog, to control the order that IncrediBuild builds projects.

Allowing Custom Build Steps to Run in Parallel

Note:

Another possible optimization is to allow custom build steps to be run simultaneously, on more than one CPU/core, in the local machine. This option is disabled by default, and can be enabled using the Agent Settings dialog Visual Studio Builds->General page.

Preventing Link Steps from Running in Parallel on the Local Machine

Allowing link steps to run in parallel on the initiating machine (assuming it has multiple cores/CPUs and has the "Multiple CPUs/Cores" extension package assigned) may sometimes result in an improvement in build performance. However, if your link steps typically consume a lot of memory and your machine does not have sufficient physical memory to support multiple link steps, this might slow down builds as a result of excessive page file swapping. It is possible to configure parallelization of link steps using the Agent Settings dialog Visual Studio Builds->General page.