Why is moc so slow when moving from qt 5.4 to qt 5.6?



  • Recently we upgraded from Qt 5.4.0 to Qt 5.6. Of the latter I don't know the exact version, because we really needed a certain fix, and we compiled a nightly version ourselves. In the near future (when we made an upcoming milestone that is) we will change over to the official released version.

    One thing we noticed though is that moc.exe seems to have gotten a lot slower. Our full project would typically build in about 30 mins. After the updates we got a full 12 minutes extra (almost 50%), and investigation seems to show this can be described to moc.exe. We run on Win7, where we use CMake to generate the solution file for the project.

    On the internet I noticed others complaining about a slow moc.exe as well, but those message always are about an upgrade from qt 4.x to qt 5.x, never about the upgrade we just performed.

    What could be the cause of this?
    Can certain (missing) compiler options cause moc.exe to run very slowly?
    Could we maybe increase performance if AUTOMOC is turned off?
    Are there changes in moc that may cause this pretty severe performance loss due to how we organize our code?


  • Lifetime Qt Champion

    Hi,

    Maybe a silly question but did you also update the CMake version ?



  • @SGaist The silly questions very often lead to the big questions, and indeed I didn't mention any details about the CMake version.

    We didn't update. We have been running CMake 3.2.3 before and after the Qt update.



  • @SGaist Just learned that on some of the build systems we also run cmake 3.3.0-rc1.

    Nevertheless, on my personal pc I actually use 3.4.0, but all these versions result in the same behaviour, and all these versions have remained the same when we upgraded the qt version.

    While typing Visual Studio just started building a project called 'Widgets', which contains all our custom QWidgets. It stuck for close to 10 minutes on the initial build step that says 'Starting build...', and in the process explorer I could tell that for all these five minutes it was continuously firing moc.exe. Then finally all the moc-files came spitting out very quickly, and the build proceeded.



  • I have now gathered some actual data. I checked our own application just before we merged the update from Qt5.4 to Qt5.6, then build the 'Widgets' library in our repository, which contains our reusable custom components. Then I checked out the revision just after that, where we merged the update.

    Before the merge, it took 1m40s to do the moc.exe runs (Qt 5.4)
    After the merge, it took 4m50s to do the same (Qt 5.6)

    So, moc.exe takes ~3 times more time for us. That I think is quite a significant performance hit, and should not happen. So I really hope someone has some pointers as to why this could happen: compiler options? Project structure?, ......


  • Lifetime Qt Champion

    Well, sounds strange that just updating Qt, the performance goes down like that.

    A quick look at the log of moc's related changes makes me think things should have gotten faster.

    Can you test a simpler project to see if you still see that performance hit ?



  • @SGaist So, last week our integrator had a moment of lucidity, and realized that we were actually using a debug-version of moc.exe instead of a release-build...........

    I did a quick test with a release build of moc.exe, which took the exact same measurement I mentioned above back to 1m10s, so indeed faster than with the 5.4-version, as you expected.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.