Priority: Not Evaluated
Affects Version/s: 2.9.1 (rev.06)
Fix Version/s: None
Component/s: Build-time integration
I'm experiencing really slow compilation time in my solution. More exactly for each and every compilations (whole solution, or single file) it takes several seconds (usually ~10 seconds) before it starts to compile a file).
I've used Cpp Build Insights (Introducing C++ Build Insights - C++ Team Blog (microsoft.com)) to track what's going on.
I've noticed that the before it starts to compile any file, it spends a lot of time in MSBuild tasks to gather information about referenced projects (GetReferencedVCProjectInfo). And it happens only with Qt projects.
To go further, I've created 2 use cases solution very similar:
- A console application with a main.cpp
- A bunch of libraries projects containing "a lot" of dummy files (.h / .cpp)
- The console application references all libraries, library 1 references libraries from 2 to 7, library 2 references libraries from 3 to 7, etc... to create a dependency graph
- All projects include some property sheets (.props)
All projects are created with the default VS templates. The 2 use cases are:
- Regular VisualC++ projects without Qt
- Qt projects
You can find these solutions attached to this ticket (Perf_WithQt, PerfWithoutQt).
The goal was to measure the compilation of the console application main.cpp file only (not the whole solution).
|Without Qt||With Qt|
|main.cpp (single file)||1.5 sec||8 sec|
Of course, the content of the 2 main files are not the same, but the problem doesn't come from the content of these files, it comes from the build system.
Now I focus on the Qt solution only. I've tested step by step like if I was building the solution from scratch:
- I create the QtConsoleApplication only, without any referenced project, without property sheet
- I add the library projects, with the referenced projects, without property sheet, without source files (empty project)
- I add the source files contained in the 'NewFolder1' sub folder for each libraries
- I add the property sheet Project.props on the console application project only
- I add the property sheet Project.props on all libraries projects
|1. Console application only||0.8 sec|
|2. Add library reference projects||1.4 sec|
|3. Add files in libraries||5 sec|
|4. Add property sheet to console application only||6.5 sec|
|5. Add property sheet to all libraries||8 sec|
So basically, to compile a single file, it's 10 times slower in this example.
This issue seems to be once per project. So for example if I notice a 10 seconds overhead to compile a single file for a particular project, I notice the same 10 seconds overhead to compile the whole project. The more a project has references, the bigger the overhead is. At work, we have about 100 projects, this become a real issue when the total overhead is 100 x [5~15 seconds].
Somehow, this overhead is more or less equal to:
overhead = [number of referenced projects] x [number of files in referenced project] x [complexity of the project settings (aka. property sheets)].
And as we saw in the table above, the biggest factor seems to be the number of files in the referenced projects.