kdeinit hack for faster apps startup and more shared memory
Lubos Lunak
l.lunak at suse.cz
Wed Jun 30 17:58:31 CEST 2004
Hello,
KDE3.2 got quite good reputation for being faster than KDE3.1. And since
(AFAIK) there haven't been any noticeable optimizations for KDE3.3, I'd like
to get in 3.3 at least the attached kdeinit hack. Done by Michael Matz,
tested by Coolo, fixed by me :).
The trick is that there are several things done on each application startup,
and these things are(?) safe to do even in kdeinit before forking. Which
means after the fork() and dlopen() of the application they'll be already
initialized, thus reducing app startup time, and since the initialization
will be done before fork() and fork() is copy-on-write, there will be also
less used memory.
Two of the pre-initialized things are fontconfig and XIM, which are currently
responsible for a significant amount of memory used by KDE, as can be seen in
http://lists.kde.org/?l=kde-optimize&m=108696117008113&w=2 . It doesn't
remove the problem completely though (looks like many pages become dirty
anyway, memory allocated by fontconfig is very fragmented), so there is still
need for a real fix in the libs, but this is better than nothing.
Coolo says he's been using this patch for months without noticing any
problem, except for kdeinit apps not picking up fonts changes, which should
be now fixed. It makes KDE startup faster (15s->14s), saves some memory (5+
MiB) and makes start of kdeinit apps faster (~125 ms). That's Athlon 1600+
(i.e. 1,4Ghz), KDE started was just plain KDE with 2xKonsole+1xKWrite.
End of the informative part.
- Any reason against shipping this with KDE3.3?
- When exactly should it be enabled (i.e. configure checks)? Are there still
Qt builds which don't use Xft+fontconfig, or would it be ok to simply
hardcode it there?
- Looks like fontconfig doesn't notice any new fonts when the app is already
running, so kdeinit needs to do an up-to-date check before launching new
apps. Fontconfig has FcInitBringUptoDate(), but I used instead the
FcConfigUptoDate() + FcInitReinitialize() combo, which avoids the interval
when fontconfig doesn't really check anything and assumes nothing has
changed. There also seems to be a bug in fontconfig causing
FcConfigUpToDate() always returning false causing rebuilding all the time,
which means with the current fontconfig the initialization is just moved from
the apps to kdeinit. I'll submit the attached patch to fontconfig devels and
see.
- Comments?
PS: Another thing worth considering might be prescanning
(http://lists.kde.org/?l=kde-optimize&m=107954681501259&w=2), at least with
the simple app that's attached to that mail. If added to the right place in
KDM and run while the user is typing login information, this could even have
no negative effect. The kernel-supported solution seems to be too complicated
for KDE3.3.
--
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o. e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27 tel: +420 2 9654 2373
190 00 Praha 9 fax: +420 2 9654 2374
Czech Republic http://www.suse.cz/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kinit.cpp.patch
Type: text/x-diff
Size: 2112 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-optimize/attachments/20040630/d6935414/kinit.cpp.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fccfg.c.patch
Type: text/x-diff
Size: 591 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-optimize/attachments/20040630/d6935414/fccfg.c.bin
More information about the Kde-optimize
mailing list