[Development] Qt Compilation Speed

Thiago Macieira thiago.macieira at intel.com
Mon Jan 3 14:21:13 CET 2022


On Monday, 3 January 2022 05:43:53 -03 Marc Mutz wrote:
> Hi,
> 
> The Qt Creator folks have noted that compilation of Qt projects against Qt
> 6.2 is sometimes almost twice as slow as it was in 5.15:
> https://bugreports.qt.io/browse/QTBUG-97601
> 
> While we have some ideas where this may come from (including more std
> headers, qmetatype compile-time typename construction, qglobal.h becoming
> larger and larger), most of these should be fixed by PCH, yet PCH builds
> are also slower.

The change to C++17 makes a huge difference too, regardless of PCH. That 
#include <algorithm> in qglobal.h adds up to 300 ms in each build without PCH, 
and a considerable amount with it too. And it gets worse with C++20 and 
ranges.

I don't know what Qt Creator used as C++ standard before 6.x, so this might be 
stale information.

We can't fix this, if it s the issue. The C++ standard is cramming more stuff 
in <algorithm>, not new headers, so it's not a QoI either.

> The questions that we face now are a) do we care and b) if we do, then what
> metrics should we use to define success?

Clang has a mode to tell you how much time it's spending on each phase. If the 
issue is headers, we can find unnecessary ones and remove them easily, with an 
automated too.

Splitting headers to make for shorter builds I'd say we can only do for a few 
headers. Find the biggest offenders in corelib and try to see what we can do. 
Some minor source compat breakage due to indirect inclusions getting removed 
is acceptable. But it's not something that can easily be done for a great deal 
many more headers: it would likely be more effort than it's worth the outcome.

And remove #include <algorithm> in qglobal.h, if we can. Maybe add a #define 
that skips including it and possibly disables some other functionality that 
you'd have to #include yourself. QGLOBAL_LEAN_AND_MEAN?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering





More information about the Development mailing list