[Qt-interest] tips for optimising cold-start Qt application startup time on Windows (and OSX)?

Martin Hofius Martin at hofius-online.com
Mon Apr 5 13:15:04 CEST 2010


Hi,

Am Montag, 5. April 2010 schrieb Ross Bencina:
> Hi Guys
>
> I'm trying to work out how to speed up my Qt application startup time on
> Windows. I've done some research and profiling. Before I spend more time
> experimenting I'm wondering if anyone has had any success improving startup
> times by using  linker function order optimisation and/or rebasing/binding
> Qt DLLs? Any other suggestions would also be great :-).
Windows is known to do strange things during a program load - first it copies 
the needed parts to the filesystem buffer, then copies this to the final 
location for executable code. This is known since Win NT4.
>
...
> When comparing cold-start (first launch after reboot, app prefetcher
> disabled) to warm-start (subsequent starts) I notice the following
> differences:
> In total my app starts in 6 seconds from cold start, and under 2 seconds
> from warm start.
> - time to reach WinMain is about 2seconds on cold start, 70ms on warm start
> - creating the QApplication instance on cold start takes 334ms, whereas it
> takes 12ms from warm start. Similar costs are observed with constructing
> other top level Qt objects like my custom QStyle and main window.
> - time from launch to display splash screen (uses Qt) ~3.8seconds on cold
> start, 200ms on warm start.
i would only use a splash screen if my program needs significant time to 
initialise data (connect to a database, load data from a database or file an 
sort data...)
>
> These times were measured by storing QPC timestamps into a global trace
> buffer and writing to disk after startup was complete. Machine was a first
> gen dual core MacBook with a 7200rpm drive running WinXP Sp2.
>
> I am assuming the 4 seconds of extra cold-start costs are mainly disk
> related due to paging in (Qt) DLLs and app code because they are not
> present on subsequent warm starts.
why should the operating system start paging any data if there is plenty of 
RAM? 
>
> Profiling did show up some inefficiencies and unexpected costs in my
> application startup code. I can get some gains by optimising my application
> code and putting some CPU-bound startup operations into a separate thread,
> however a big part of the extra startup cost on cold start seems to be due
> to dll loading before my main() is called. If I had a way of deferring some
> of this cost I could get my CPU-bound work started earlier and mask some of
> the DLL load time.
>
> Any thoughts appreciated!
What about link your program statically? =>
- your program will start up faster and user less memory IF YOUR program is 
the ONLY prog using these Qt libs
- the overall amount of code to deploy with your program maybe smaller because 
the linker can omit unused parts of the libs
- deploying is simpler

ok, you may have a bigger impact on your system if there a more the on Qt 
program. 


Greetings
Martin



More information about the Qt-interest-old mailing list