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. Incredibly slow moc - any gotchas I should be aware of?

Incredibly slow moc - any gotchas I should be aware of?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 826 Views
  • 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.
  • I Offline
    I Offline
    ivanisavich
    wrote on 23 Jun 2022, 18:35 last edited by
    #1

    I'm using Qt 5.6.2 on a project (for compatibility reasons) and the moc is taking 5+ minutes PER header file (and I have hundreds of headers which contain different qt classes, so the moc alone takes hours to run). Thankfully I don't have to recompile the project often, but this is still unbelievably and unbearably slow.

    Surely there must be an explanation for the slow compile time....the headers themselves are nominal in size and the resulting moc*.cpp files are less than 100 lines long...so what the moc is actually wasting all this time doing is a mystery. The task manager shows moc.exe processes running at 0-1% CPU usage during compilation, with steadily increasing RAM usage.

    The project contains a lot of different dependencies and so it's not easy for me to reproduce the issue in a vacuum or post the code. So, barring any specifics, are there any moc 'gotchas' that I should be aware of, which could be the culprit? Things which could dramatically increase moc time in some cases? Or is there some other way to debug what the moc is spinning its wheels on?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Jun 2022, 18:41 last edited by
      #2

      Hi,

      Is your code base stored locally ?
      If so, what kind of disk is that ?
      Are you including lots of headers in these headers ?
      Do your dependencies do that ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ivanisavich
        wrote on 23 Jun 2022, 18:46 last edited by
        #3

        Yes, locally on an SSD. I don't think read/write is the issue.

        I don't have a ton of header includes but perhaps there's some nested expansion in one of my dependencies that's causing the issue...I'm trying to pair things down and remove everything from the headers that isn't completely necessary to the Qt class definitions. But still....the entire project which contains thousands of non-moc'd headers compiles nearly an order of magnitude faster than it takes for the moc to run and generate a couple hundred 4kb files. Does the moc run considerably faster in newer versions of Qt?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 23 Jun 2022, 18:50 last edited by
          #4

          Having minimal includes is always better. Everything that you can forward declare should be.

          I never had performance issues with moc so I can't tell whether newer versions would be faster but I doubt it in the sense that moc does a single job and has not changed much to the best of my knowledge.

          Do you have macros in your headers ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ivanisavich
            wrote on 23 Jun 2022, 18:57 last edited by
            #5

            I have macros, yes. Do they not play well with the moc?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 23 Jun 2022, 18:59 last edited by
              #6

              moc used to not expand them and if memory serves well it started with Qt 5 so I wonder if there's something going on with that.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 23 Jun 2022, 20:22 last edited by
                #7

                I still would guess it's a include problem - I've a similar problem in one of my projects at work where a lot of includes are in the headers which slows down moc, esp. on windows.

                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
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 24 Jun 2022, 20:25 last edited by
                  #8

                  There was a thread on the Qt mailing list about that matter. One of the issue was also the way the included were done. Lots of headers within the same directory. Moving them to a separate folder and using specific "path/include.h" helped one that front as well.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  2/8

                  23 Jun 2022, 18:41

                  6 unread
                  • Login

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