Introducing C++ Build Insights
C++ builds should always be faster. In Visual Studio 2019 16.2, we’ve shown our commitment to this ideal by speeding up the linker significantly. Today, we are thrilled to announce a new collection of tools that will give you the power to make improvements of your own. If you’ve ever had time for breakfast while building C++, then you may have asked yourself: what is the compiler doing? C++ Build Insights is our latest take at answering this daunting question and many others. By combining new tools with tried-and-tested Event Tracing for Windows (ETW), we’re making timing information for our C++ toolchain more accessible than ever before. Use it to make decisions tailored to your build scenarios and improve your build times.
Capturing timing information for your build boils down to these four steps:
- Launch an x64 Native Tools Command Prompt for VS 2019 Preview as an administrator.
- Run: vcperf /start MySessionName
- Build your project.
- Run: vcperf /stop MySessionName myTrace.etl
Choose a name for your session and for your trace file. After executing the stop command, all information pertaining to your build will be stored in the myTrace.etl file.
ETW allows C++ Build Insights to collect information from all compilers and linkers running on your system. You don’t need to build your project from the same command prompt as the one you are using vcperf from. You can either use a different command prompt, or even Visual Studio.
Another advantage of ETW is that you don’t need to add any compiler or linker switches to collect information because the operating system activates logging on your behalf. For this reason, C++ Build Insights will work with any build system, no configuration necessary!
Once you’ve collected your trace, open it in Windows Performance Analyzer (WPA). This application is part of the Windows Performance Toolkit. Details on which version of WPA you need to view C++ Build Insights traces can be found in the Getting started documentation page.
In the following sections, we show you a glimpse of what you will find after opening your trace in WPA. We hope to convince you to try out these new tools and explore your build!
At the crux of the matter with the Build Explorer
Central to understanding a build is having an overview of what happened through time. The Build Explorer is a core element of C++ Build Insights that we designed for this purpose. Drag it from the Graph Explorer panel on the left onto the main analysis window in WPA. Use it to diagnose parallelism issues, detect bottlenecks, and determine if your build is dominated by parsing, code generation, or linking.
A thousand scoffs for the thousand cuts: aggregated statistics
The most insidious of build time problems are the ones that strike you little by little until the damage is so large that you wonder what hit you. A common example is the repetitive parsing of the same header file due to its inclusion in many translation units. Each inclusion may not have a large impact by itself but may have devastating effects on build times when combined with others. C++ Build Insights provides aggregated statistics to assist you in warding off such threats. An example of this capability is illustrated below, where file parsing statistics are aggregated over an entire build to determine the most time-consuming headers. To view this information for your build, choose the Files view from the Graph Explorer panel on the left in WPA. Drag it to the analysis window.
What information can you get?
With C++ Build Insights, expect to be able to obtain the following information for all your compiler and linker invocations.
Tell us what you think!
In this article, we shared two features with you, but there is much more to come! Stay tuned for more blog posts detailing specific ways in which you can use C++ Build Insights to improve your builds.
We look forward to hearing from you on how you used vcperf and WPA to understand and optimize your builds. Are there any other pieces of information you would like to be able to get from C++ Build Insights? Tell us what you think in the comments below. You can also get in touch with us at email@example.com, or on Twitter @VisualC.