MSBuild Flame Graph
Explore MSBuild executions to find why your C++ builds are slow.
This is the flame graph for a default Visual Studio 2015 C++ project:
This graph represents a build from this repository.
I wrote about the steps I took to build the initial version of the tool in this post series.
- Uses MSBuild 15: builds VS2015 and VS2017 C++ projects.
/d1reportTimeMSVC flag (exclusive to VS2017 projects):
- Builds projects into an
Events.jsonfile, converts it into
Trace.jsonin a separate step.
- Can theoretically build other MSBuild-based projects, but is only tested on C++ ones.
- Install Visual Studio 2017+ Community Edition.
- Install .NET Framework v4.6.2 SDK.
- Clone repository.
- Open solution, build and run.
Should you want to explore what's in the repository, these are the main parts:
Builder: contains the UI (built in WPF) to interact with the tool.
MSBuildWrapper: defines MSBuild loggers, interacts with MSBuild API and converts MSBuild events to custom abstractions.
BuildTimeline: represents timelines and everything it needs, from events to entries.
TimelineSerializer: includes a way to convert a
Timelineto a Google Chrome's trace. New trace formats can be added.
Model: represents data to be used by other projects.
- As part of
MSBuildWrapper/Compilation/Compilation.cs, when a build starts every MSBuild event is displayed in the UI and gets stored in memory.
- When the build finishes, most events get converted into a custom format (some events and properties are discarded).
- When the build is finished,
Builder/ViewModel/Commands.csstores every custom event in an
Trace.jsonfile can be exported from an
Builder/ViewModel/Commands.cs. This is useful to build different timelines (even to different formats) without having to repeat the build.
This project is released under GNU GPLv3 license.
I started this project thanks to the information I gathered from the community, so I wanted to give something back. You are encouraged to alter it in any way you want, but please continue making it public so the community can benefit from it.