Compilation times with Qt6
-
After upgrading my project from Qt5 to Qt6, I noticed a massive slowdown when compiling my project. Using cmake in Qt Creator, the project takes about twice as long to compile.
Since my code hasn't changed that much, I suspect Qt header includes to cause the slowdown.Has anyone else noticed this?
Any hints on how to improve compilation times? -
After upgrading my project from Qt5 to Qt6, I noticed a massive slowdown when compiling my project. Using cmake in Qt Creator, the project takes about twice as long to compile.
Since my code hasn't changed that much, I suspect Qt header includes to cause the slowdown.Has anyone else noticed this?
Any hints on how to improve compilation times?@Asperamanca Do you have more than one build job? Like "make -j NUMBER_OF_BUILD_JOBS"
-
@Asperamanca Do you have more than one build job? Like "make -j NUMBER_OF_BUILD_JOBS"
@jsulm
Not that I am aware of. It's basically the same cmakelists.txt file for Qt5 and Qt6, just with the necessary changes to enable Qt6.
I also made sure there were no background tasks running when I measured the compilation times. -
@jsulm
Not that I am aware of. It's basically the same cmakelists.txt file for Qt5 and Qt6, just with the necessary changes to enable Qt6.
I also made sure there were no background tasks running when I measured the compilation times.@Asperamanca
If that better answers your question:
Both in Qt5 and Qt6 build, my CPUs are fully busy for the duration of the build process. I also made sure no background tasks run while I measure the build time. -
Qt6 defaults to c++17, Qt5 to c++11 so the compiler may be slower because of the c++17 mode.
-
Good hint, but I did already used C++17 for my project. So that shouldn't have changed.
My hunch is that it's tied to the new compile-time metatype analysis and registration, at least partially.
-
Good hint, but I did already used C++17 for my project. So that shouldn't have changed.
My hunch is that it's tied to the new compile-time metatype analysis and registration, at least partially.
@Asperamanca
The effect is also apparent in Visual Studio using MSBuild. So it's not cmake-specific -
I have now profiled compilation using Qt5 and Qt6 using vcperf.
This shows that, e.g. including qchar.h used about 600 ms in Qt5, but almost 2500 ms in Qt6.
For example, qchar.h now includes <functional> (which it didn't in Qt5), and that alone costs 600 ms.I think I'll look into using precompiled headers for Qt...
-
I have now profiled compilation using Qt5 and Qt6 using vcperf.
This shows that, e.g. including qchar.h used about 600 ms in Qt5, but almost 2500 ms in Qt6.
For example, qchar.h now includes <functional> (which it didn't in Qt5), and that alone costs 600 ms.I think I'll look into using precompiled headers for Qt...
@Asperamanca said in Compilation times with Qt6:
For example, qchar.h now includes <functional> (which it didn't in Qt5), and that alone costs 600 ms.
Depressing :(
I don't mean to be too mean, but most that I see about Qt6 depresses me. You seem to get not-a-lot-more at the expense of a lot of issues.... :(
Sigh. This seems to be the way with much software when you "upgrade".... -
@Asperamanca said in Compilation times with Qt6:
For example, qchar.h now includes <functional> (which it didn't in Qt5), and that alone costs 600 ms.
Depressing :(
I don't mean to be too mean, but most that I see about Qt6 depresses me. You seem to get not-a-lot-more at the expense of a lot of issues.... :(
Sigh. This seems to be the way with much software when you "upgrade"....@JonB
There are a lot of improvements, new features and bugfixes, so for me it's more a mixed bag.
And the compilation time goes down rapidly when using precompiled headers. -
@JonB
There are a lot of improvements, new features and bugfixes, so for me it's more a mixed bag.
And the compilation time goes down rapidly when using precompiled headers.@Asperamanca Would be interesting to compare compilation times of your project for MSVC and MinGW.
-
@Asperamanca Would be interesting to compare compilation times of your project for MSVC and MinGW.
@jsulm
Unfortunately, not easy to do, as my project won't build on MinGW out of the box. Old code, old defines...
I have since read about Header Units, and C++20 Modules. I'll certainly suggest that Qt provide pre-generated Header Units that people already on C++20 can optionally use instead of #include for Qt headers. -
After upgrading my project from Qt5 to Qt6, I noticed a massive slowdown when compiling my project. Using cmake in Qt Creator, the project takes about twice as long to compile.
Since my code hasn't changed that much, I suspect Qt header includes to cause the slowdown.Has anyone else noticed this?
Any hints on how to improve compilation times?@Asperamanca We face the same issues, our big cmake project build (which was already using precompiled headers) slowed down about 3x times slower when moving to Qt6.
It may be related to Qt now using std containers now and std headers everywhere...
If you find something for speeding this up please share :) -
@Asperamanca We face the same issues, our big cmake project build (which was already using precompiled headers) slowed down about 3x times slower when moving to Qt6.
It may be related to Qt now using std containers now and std headers everywhere...
If you find something for speeding this up please share :)@AlGrenadine So, my next PC will be about 3x faster than the current one. That's currently my only solution :-(
You can measure compile times using tools such as Compile Score (VS extension, but similar one certainly exist for other IDEs or command line builds). Maybe you can find some header files within your control that are slow to include, and can be optimized through separation and aggressive use of forward declarations...
-
@AlGrenadine So, my next PC will be about 3x faster than the current one. That's currently my only solution :-(
You can measure compile times using tools such as Compile Score (VS extension, but similar one certainly exist for other IDEs or command line builds). Maybe you can find some header files within your control that are slow to include, and can be optimized through separation and aggressive use of forward declarations...
That's the price compiling something with c++17 instead c++11 support - even though Qt6 is affected here much.
-
That's the price compiling something with c++17 instead c++11 support - even though Qt6 is affected here much.
@Christian-Ehrlicher Hoping for C++ Modules in Qt before I retire...
-
@Christian-Ehrlicher Hoping for C++ Modules in Qt before I retire...
@Asperamanca said in Compilation times with Qt6:
Hoping for C++ Modules in Qt before I retire...
I would not bet on this - from my pov there is way to much work to be done before such a big framework as Qt can use them properly.
-
C Christian Ehrlicher referenced this topic on