Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Compilation times with Qt6
Forum Updated to NodeBB v4.3 + New Features

Compilation times with Qt6

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 5 Posters 2.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    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?

    jsulmJ A 2 Replies Last reply
    0
    • A Asperamanca

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Asperamanca Do you have more than one build job? Like "make -j NUMBER_OF_BUILD_JOBS"

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Asperamanca Do you have more than one build job? Like "make -j NUMBER_OF_BUILD_JOBS"

        A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        @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.

        A 1 Reply Last reply
        0
        • A Asperamanca

          @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.

          A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Qt6 defaults to c++17, Qt5 to c++11 so the compiler may be slower because of the c++17 mode.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #6

              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.

              A 1 Reply Last reply
              0
              • A Asperamanca

                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.

                A Offline
                A Offline
                Asperamanca
                wrote on last edited by
                #7

                @Asperamanca
                The effect is also apparent in Visual Studio using MSBuild. So it's not cmake-specific

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Asperamanca
                  wrote on last edited by
                  #8

                  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...

                  JonBJ 1 Reply Last reply
                  0
                  • A Asperamanca

                    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...

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #9

                    @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"....

                    A 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @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"....

                      A Offline
                      A Offline
                      Asperamanca
                      wrote on last edited by
                      #10

                      @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.

                      jsulmJ 1 Reply Last reply
                      0
                      • A Asperamanca

                        @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.

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @Asperamanca Would be interesting to compare compilation times of your project for MSVC and MinGW.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        A 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @Asperamanca Would be interesting to compare compilation times of your project for MSVC and MinGW.

                          A Offline
                          A Offline
                          Asperamanca
                          wrote on last edited by
                          #12

                          @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.

                          1 Reply Last reply
                          0
                          • A Asperamanca

                            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?

                            A Offline
                            A Offline
                            AlGrenadine
                            wrote on last edited by
                            #13

                            @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 :)

                            A 1 Reply Last reply
                            0
                            • A AlGrenadine

                              @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 :)

                              A Offline
                              A Offline
                              Asperamanca
                              wrote on last edited by
                              #14

                              @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...

                              Christian EhrlicherC 1 Reply Last reply
                              0
                              • A Asperamanca

                                @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...

                                Christian EhrlicherC Offline
                                Christian EhrlicherC Offline
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                That's the price compiling something with c++17 instead c++11 support - even though Qt6 is affected here much.

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                A 1 Reply Last reply
                                1
                                • Christian EhrlicherC Christian Ehrlicher

                                  That's the price compiling something with c++17 instead c++11 support - even though Qt6 is affected here much.

                                  A Offline
                                  A Offline
                                  Asperamanca
                                  wrote on last edited by
                                  #16

                                  @Christian-Ehrlicher Hoping for C++ Modules in Qt before I retire...

                                  Christian EhrlicherC 1 Reply Last reply
                                  0
                                  • A Asperamanca

                                    @Christian-Ehrlicher Hoping for C++ Modules in Qt before I retire...

                                    Christian EhrlicherC Offline
                                    Christian EhrlicherC Offline
                                    Christian Ehrlicher
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    @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.

                                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                    Visit the Qt Academy at https://academy.qt.io/catalog

                                    1 Reply Last reply
                                    0
                                    • Christian EhrlicherC Christian Ehrlicher referenced this topic on

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved