[Computer] What is concidered when/while compiling?

  • Hello everyone I have been recently working between versions of Qt as of 4.7.0 to 5.0.0 and well the compiles has been pretty much straight forward, but I see some differences between Static builds and Shared builds... When I build programs with shared libraries it just compiles like a charm., fast, smooth and with few delay in each build or whatsoever, but in the other hand when I build programs in Static build of Qt using Static libraires... it slows a lot (in GUI Applications) and in Console Apps is kinda off half the time than static gui apps... -still having a little bit of delay-

    So this question popped up in my mind... What is concidered while compiling? CPU or RAM? or a combination of both? because if this could help, I'm willing to upgrade my PC specs from:

    AMD Athlon Dual Core @ 2.50GHz > AMD Phenom II X4 965 Black Edition 3.4GHz Quad-Core Processor
    4GB RAM > 8 GB RAM

    So I just wanted to know, by upgrading my system specs to the new ones, will I have an improve on compilations in my system?

    Thanks for the reviews and opinions.

    [Moderator note: Moved this post to The Lounge -- mlong]

  • Moderators

    You can pass -j to speed things up. A faster CPU will sure make a difference. Boosting RAM from 4 to 8 GB will not make any difference (unless, of course, you are compiling some real monster app). Big RAM usage occurs usually at linking, CPU is more important when compiling.

    Static builds will always be slower, because you are actually including the library (and QtGui is a big one) in your executable. That is slower than just linking to an external .so.

  • There are four more things to consider, the compiler, the compilation process, the application design and I/O.

    MSVC is generally considered to compile faster then MinGW, although MinGW has caught up lately, linking is still a bit of a problem.

    make does not build in parallel by default, so only one core is usually used. As sierdzio already mentioned, you can use <code>-j</code> to do parallel builds (be aware that you will need a recent make for this to work properly). In addition, the use of precompiled headers can have a severe impact on compilation time.

    The application design can also significantly affect the compilation process positively or negatively. Use d-pointers when applicable, use forward declarations and use class-includes, not module-includes (<code>#include <QLabel></code> instead of <code>#include <QtWidgets></code>).

    In addition, compilation and linking is pretty much I/O bound, as the compiler and linker has to open, read/write and close source and temporary files constantly. So replacing your HDD with an SDD will have more impact on your compilation speed then for instance upgrading your RAM.

    Upgrading your hardware will make a difference, but using a proper compilation system and application design will usually be more effective.

  • Moderators

    I focused on hardware since that is what OP mentions. Lukas is absolutely right, though - taking a look at your build process can actually give much better (and cheaper) performance gains.

    In a big project I recently was tasked to optimise, just using forward declarations and specific includes (no module includes) sped up the compilation by almost 40%.

    Going back to hardware for a moment - using -j flag for make can be especially powerful if you have lots of cores. Compilation of Qt5 used to take me ~4 hours on an old Core2Duo. After upgrading to i7QM (4 cores + HT), it now compiles in... 26 minutes.

  • The compilation process, especially when it comes to GCC, MSVC and even IC is morally outdated and bloated. An example of how much this is true is the tremendously faster compilation time of Clang/LLVM which is much newer and overall better done.

    !http://clang.llvm.org/feature-compile1.png( )!
    !http://clang.llvm.org/feature-memory1.png( )!
    !http://clang.llvm.org/feature-compile2.png( )!

  • Wowowow! I have been reading all the information you guys provided in this thread and I'm amazed! Thanks really thanks for helping me out in this... I will definitely buy the new CPU although I want more RAM just because, so I will buy those 8 Gigs too =D and for the -J option I never knew that if it weren't from you guys, also the is a n variable in that argument.. what's the number i'm supposed to enter?

    Thank you very much!

    Note: Btw I'm using the MSVC2010 Compiler for Qt 4.8.4 Static Build Version < Which is why I originally opened this thread =D

  • Moderators

    -j <number of cores>. If you don't specify, make will guess.

    Since you are using MSVC, though, this is not - AFAIK - available to you (thank MS for inventing nmake). You need to use jom instead, I think it ships with Qt.

  • Yes it's fine the -J option is available for JOM and I just compiled with it =D Although this is what happens when u use no integer in the argument:

    @jom only options:
    /DUMPGRAPH show the generated dependency graph
    /DUMPGRAPHDOT dump dependency graph in dot format
    /J <n> use up to n processes in parallel
    /KEEPTEMPFILES keep all temporary files
    /VERSION print version and exit
    Error: no process count specified for option -j
    14:36:19: The process "C:\Qt\qtcreator-2.6.0\bin\jom.exe" exited with code 128.
    Error while building/deploying project MutiServer (target: Desktop)
    When executing step 'Make'@

    but like I said I just added -j 2 and it worked like charm =D

  • Moderators

    Good, then we both learned something here :)

Log in to reply

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