generate slow / pauses for > 30 seconds starting with 3.21

Since I can remember, on Windows, for our project (open_iA), there was a short “pause” at the beginning of the “generate” phase; meaning, for example in the GUI, there is no visual feedback in the first few seconds after pressing the Generate button, only then the progress bar starts to indicate progress.

I never put much thought into it so far as it went by very quickly, but starting with 3.21, we see a steep increase in this “pause” time, as compared to 3.20.x:

  • With 3.20.5, the pause is ~3-5 seconds
  • With 3.21, the pause increased more than 6-fold to over 30 seconds.

To investigate where this pause is coming from, I’ve tried playing around with --debug-output and --trace options to cmake, but in that pause, there is no output on the command line - the last output line is “Configuring done”, and no output occurs during the pause.

Does anybody have an idea where this pause / the slowdown between 3.20 and 3.21 could come from?
I do suspect it’s something that’s not set up ideally in our cmake files that’s causing this, because other examples run fast with 3.21 on the same machine; I just don’t have any idea how to debug this any further - so thanks in advance for any hints!

This is likely due to some change in genex evaluation. Or there are simply far more genexes in 3.21. A bisection of CMake itself to find out where the performance difference was introduced would be nice to have (git bisect --first-parent is likely to be accurate enough).

1 Like

Thanks for the git bisect hint!

The result:

98d813b92c26f0c93cefe21fe7768ca4f73d2d9a is the first bad commit
commit 98d813b92c26f0c93cefe21fe7768ca4f73d2d9a
Merge: 2f7c4a788c e5ec0e52f4
Author: Brad King
Date:   Mon Jul 26 13:34:23 2021 +0000

    Merge topic 'autouic-header-depends' into release-3.21

    e5ec0e52f4 AUTOUIC: Fix generating of dependency rules for UI header files

    Acked-by: Kitware Robot
    Merge-request: !6380

 Source/CMakeLists.txt                              |  2 +
 Source/cmQtAutoGen.cxx                             | 36 +++++++++++++++
 Source/cmQtAutoGen.h                               |  3 ++
 Source/cmQtAutoGenInitializer.cxx                  | 53 +++++++++++-----------
 Source/cmQtAutoGenInitializer.h                    |  2 +
 Source/cmQtAutoGenerator.cxx                       | 37 ---------------
 Source/cmQtAutoGenerator.h                         |  2 -
 Source/cmQtAutoMocUic.cxx                          | 20 ++------
 Source/cmQtAutoUicHelpers.cxx                      | 25 ++++++++++
 Source/cmQtAutoUicHelpers.h                        | 20 ++++++++
 .../QtAutogen/RerunUicOnFileChange/CMakeLists.txt  |  3 ++
 .../UicOnFileChange/              |  4 +-
 .../RerunUicOnFileChange/UicOnFileChange/main.cpp  |  4 +-
 .../UicOnFileChange/subdir/  |  7 +++
 .../UicOnFileChange/subdir/subdircheck.cpp         |  9 ++++
 15 files changed, 144 insertions(+), 83 deletions(-)
 create mode 100644 Source/cmQtAutoUicHelpers.cxx
 create mode 100644 Source/cmQtAutoUicHelpers.h
 create mode 100644 Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/
 create mode 100644 Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/subdircheck.cp

Since this merge has to do with the autouic process - we are using AUTOUIC; and that reminds me that with 3.21 another peculiarity started in our project: For all targets created in a subdirectory, now all generated ui_xyz.h files are added to each targets’ (Visual Studio) project (all .ui files from all targets are included in all targets - altough each of them is only referenced in the source files of a single target - and that four times, once for each configured build type in the VS multi-config generator); before (i.e. with 3.20.x and less), they were not shown in the project at all. The addition of these files to the project seems mostly “cosmetical”, but probably has to do with being able to properly resolve dependencies?

The .ui files for the targets are in separate subfolders (one for each target), and the source files for each target only include those in the respective subfolder, and only the correct .h files for each single target are in the target- and configuration-specific subfolder in the build directory (e.g. if the target’s name is Test, they get created in Test_autogen/include_(Debug|Release|…) - so I’m not sure why CMake does add all ui_xyz.h files to all targets…


Hmm. I’m not that familiar with the autogen machinery, unfortunately. Thanks for the bisect though.

Cc: @brad.king

That commit was just a merge that I made. The actual change was from another author, in CMake MR 6380.

Please open an issue to report this problem. See also CMake Issue 22531.

1 Like

CMake MR 6465 reverts that change. I mentioned this report over in CMake Issue 16776, the original issue that motivated the change in the first place.

1 Like