Results 1 to 15 of 15

Thread: Very slow startup by the first run

  1. #1
    Join Date
    Aug 2011
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Very slow startup by the first run

    Hi, I am writing a qt app for an embedded linux platform based on Freescale 5121 PPC core. The Qt version I am using is 4.7.2 static compiled.
    The system boots over network and mounts a rootfs over nfs.

    I made the following tests:
    A small gui app showing only a couple of colored boxes takes over 20 secs to start by the first call. Wenn I quit the app and start it again, it starts instantly.

    My first thought was the long load time over nfs (the staticly linked app is about 11 Megs), so I then copied the app into /tmp, which is mounted as tmpfs, meaning almost no load delays. This also didn't change the above behaviour.

    Switching to dynamic linking didn't help.

    Then I wrote the following app:
    Qt Code:
    1. int main(....)
    2. {
    3. QCoreApplication a(argc,argv);
    4. qDebug() << "test";
    5. return a.exec();
    6. }
    To copy to clipboard, switch view to plain text mode 

    this code ( resulting in about 2 Megs) did also show almost the same behaviour, except the delay was about 15 secs.

    the apps are all release versions with -O2 compiled

    a pure "C" HelloWorld programm with printf does start always instantly.

    Any ideas, what to optimize/change or where to begin looking for the bottlenecks?
    Last edited by high_flyer; 31st August 2011 at 16:50. Reason: code tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    Are you using release Qt libs as well?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2011
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    The first 2 apps (gui and qDebug) use qt libs. Both staticly linked. But I also tried with dynamic linked qt libs too.

    To find out if the delay was Qt related, I wrote also a small "pure C" without Qt, which doesn't show this behaviour.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    You didn't answered my question.
    The Qt libs you use are they release or debug versions?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Aug 2011
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    release versions

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Very slow startup by the first run

    Qt probably generates a plugin cache or something like that on the first load. Or it might not be Qt's fault after all but rather the linker's.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2011
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    Quote Originally Posted by wysota View Post
    Qt probably generates a plugin cache or something like that on the first load. Or it might not be Qt's fault after all but rather the linker's.
    First I thought about these possibilities too, but at configuration level before compiling Qt, all plugins are deselected (image libs such as gif/jpeg/png, sql-related plugins, directfb an co...). Only Linux Framebuffer is as "built-in" selected.

    Regarding linker, thats why I also tested with a pure C "hello world", which runs very well. Also on another target with the same CPU-platform, we use framebuffer to show video with linux media interface (V4L2), where everything starts in 4 secs (including u-boot, kernel and canbus).

    We get into these first-start-delay problems only when qt is involved...

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Very slow startup by the first run

    Quote Originally Posted by denizlitr View Post
    First I thought about these possibilities too, but at configuration level before compiling Qt, all plugins are deselected (image libs such as gif/jpeg/png, sql-related plugins, directfb an co...). Only Linux Framebuffer is as "built-in" selected.
    Nevertheless the cache is built.

    Regarding linker, thats why I also tested with a pure C "hello world", which runs very well.
    A pure C hello world doesn't link to all those libraries a full blown Qt app does.

    We get into these first-start-delay problems only when qt is involved...
    I can only suggest to profile the app and see where the delays occur.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Aug 2011
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    I began debugging the different phases of a test programm, which does show only a window with a red rectangle in the middle. The programm is normally startet with the commandline:

    /bin/test -qws -display LinuxFB

    which takes about 25 secs to show this rect.

    I changed the main(..) to this:

    Qt Code:
    1. int main(....)
    2. {
    3. printf("Begin qapp\n");
    4. QApplication a(argc,argv);
    5.  
    6. printf("Begin mainwindow\n");
    7. MyMainWindow w;
    8.  
    9. printf("Begin qdebug\n");
    10. qDebug() << "test";
    11.  
    12. printf("Begin mainwindow show\n");
    13. w.show();
    14.  
    15. printf("End Init\n");
    16.  
    17. return a.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 
    I start the app with
    $> LD_DEBUG=all /bin/colortest -qws -display LinuxFB

    and I see that the longest delay (about 90 % of the startup time) ocuurs at the init of QApplication (the construction of the qapp object).

    Any ideas how I can find the, what causes the delay in this constructor ?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Very slow startup by the first run

    You can profile the application as already suggested. Also test your app against an already running qws.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Aug 2011
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    Quote Originally Posted by wysota View Post
    You can profile the application as already suggested. Also test your app against an already running qws.
    Any application linked with qt starts very slow. In this case starting a qws app would take very long, even if the second app would start fast, meaning the whole system is ready still after a long time. On the other side, I observed that a console qt-application inheriting from qcoreapplication, which doesn't need qws, takes about 15 secs, still veeeery long.

    I found that at startup, most of the time is consumed during instantiating QApplication/QCoreApplication. Now I am going to add some printfs with time outputs in the source of Qt to find what takes soo long.

    What I don't get, is, why the app starts on the second try almost instantly. The whole app is linked static (except libc and co.). So as you said the qapp must be building something wenn first called, and that is in cache by the second call...

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Very slow startup by the first run

    I already told you -- at the first run the plugin cache is built. Maybe something causes it to execute so long.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Jan 2016
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very slow startup by the first run

    Hi,

    I,m experiencing the same problem while running a Qt app on Atmel board with ARM processor running embedded Linux 2.6.31
    Anything new about this?

  14. #14
    Join Date
    Oct 2016
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Android

    Default Re: Very slow startup by the first run

    Qt probably generates a plugin cache or something like that on the first load. Or it might not be Qt's fault after all but rather the linker's.

  15. #15
    Join Date
    Oct 2016
    Posts
    6
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Very slow startup by the first run

    To find out if the delay was Qt related, I wrote also a small "pure C" without Qt, which doesn't show this behaviour.

Similar Threads

  1. (GUI) how to run code on program startup
    By qtierer in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2011, 20:15
  2. How can i select a row at startup
    By kosasker in forum Newbie
    Replies: 3
    Last Post: 1st February 2011, 14:25
  3. Qt app in linux startup
    By qtlinuxnewbie in forum Newbie
    Replies: 8
    Last Post: 2nd March 2010, 19:37
  4. QT Creator crashed on startup
    By eloos in forum Qt Tools
    Replies: 13
    Last Post: 20th November 2009, 09:50
  5. QToolBar go away! On startup anyway.
    By bitChanger in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2006, 19:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.