[Qt-interest] tips for optimising cold-start Qt application startup time on Windows (and OSX)?
Ross Bencina
rossb-lists at audiomulch.com
Mon Apr 5 07:36:08 CEST 2010
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 :-).
I wanted to experiment with delay loading the Qt DLLs so I could display a
native splash screen before incurring the load time, but this doesn't seem
possible (see http://bugreports.qt.nokia.com/browse/QTBUG-8552).
My app only depends on QtCore.dll and QtGui.dll. I'm going to investigate on
OSX also, so I'd be interested in tips for OSX too.
FYI, here's a summary of what I've found so far:
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.
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.
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!
Thanks
Ross.
More information about the Qt-interest-old
mailing list