[Qt-interest] Making a Qt program into a dynamic library
Thiago Macieira
thiago at kde.org
Thu Dec 17 20:46:23 CET 2009
Em Quinta-feira 17. Dezembro 2009, às 15.28.50, Allan Sandfeld Jensen
escreveu:
> On Wednesday 16 December 2009, Oliver.Knoll at comit.ch wrote:
> > Why would this speed up an application? I would expect that this would
> > take even longer (compared to a single huge executable which is loaded at
> > once into memory), since dynamic linkage also takes its time. Or do you
> > mean "Code is only dynamically loaded/linked when actually needed?"
>
> No, it loaded the entire executable binary as a dynamic libary. C++ linking
> was very expensive in earlier binutils, and before hidden symbols support
> from gcc and Qt. Being loading from an application that already was linked
> to most libraries you used, meant only your own symbols needed to be
> linked instead of all symbols in all the libraries you used. This reduced
> startup time for KDE applications from 10 seconds to around 1 second.
>
> Even today this trick is still marginally faster, but it is not a killer
> like it used to be.
Oliver is right: it's more expensive if you compare to one application's
loading.
But this is used for many applications, most of which at KDE startup. It
probably breaks even at 2 or 3 applications (I'm guessing here). And it keeps
paying off whenever you launch any application that uses the "kdeinit trick".
The same trick allows us to hide the "NVidia cost". Since NVidia's
libGLcore.so.1 is *not* position-independent code, it costs about 10 MB per
process linking to QtOpenGL, in terms of non-sharable code segments. That cost
you pay simply by linking -- you don't have to use OpenGL at all. We hide the
cost by preloading libplasma (which links to QtWebKit and QtOpenGL) and
sharing their non-sharable code segments.
Since at least plasma-desktop and kwin are constantly running on a KDE
workspace, we've saved you already 10 MB of memory. If you use Amarok -- which
also links to libplasma -- then it's another 10 MB saved.
Maemo also uses the same trick on the N900.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091217/d67cbf7c/attachment.bin
More information about the Qt-interest-old
mailing list