[Xorg] [PATCH] Cached XIM data

Lubos Lunak l.lunak at suse.cz
Mon Aug 9 10:27:51 PDT 2004


 Hello,

 could somebody please review the attached XIM patches?

 First, the rationale: QApplication constructor (app class in Qt) takes about 
0.08s on my computer (850Mhz). But only in case I dump my Compose file and 
all fonts. With the Compose file it's 0.31s  (and with fonts it goes up to 
0.47s, but that's fontconfig, so let's ignore that one). There's also about 
500KiB (unshared) memory difference. Multiply this quarter a second and half 
a meg e.g. by the number of apps with X connection in normal KDE session to 
get even worse numbers. All this just for the ability to compose accented 
characters.

 The problem is basically that XIM parses the matching Compose file 
from /usr/X11R6/lib/X11/locale (which happens to be the huge 
en_US.UTF-8 one for UTF8 locales) and builds internal representation of this 
data. The file is more or less constant, but XIM parses it once per 
application startup.

 The imLcIm.c patch tries to solve this problem in similar way KDE's ksycoca 
stores data. After XIM parses the Compose file, the code computes how much 
memory the internal representation needs, allocates such block of memory, and 
copies the internal representation there, including adjusting the pointers. 
This avoids malloc() overhead, and allows read-only mmap()-ing of the block 
(the internal representation doesn't appear to be ever modified after it's 
created). Next time it's attempted to be mmap()-ed at the proper address, and 
if that succeeds, bingo, QApplication time is again at 0.08s. Still without 
the fonts of course, fontconfig needs something similar.

 The second patch caches a repeatedly requested information that is parsed 
from another file.

 There are several things I'm unsure about the patch:

- It uses things like mmap() or posix_memalign() which could cause trouble to 
all those crappy Nulix platforms out there. It should be just a matter of few 
#ifdef's, but I don't know how you do checks for such features.

- I'm not sure where to store the cache file. KDE has special place for cache 
files, but I don't know how to do that with non-KDE apps. The patch now 
stores it in /tmp/xim, the /var/X11R6/cache/ or /var/cache are Linux-ism 
AFAIK. Moreover this should be probably saved per-user for paranoia reasons, 
or shouldn't it?

 Could somebody helps me with these issues? Comments?

 Thanks

PS: The patches are for libX11.

-- 
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: lcFile.c.patch
Type: text/x-diff
Size: 1070 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20040809/a4b80303/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imLcIm.c.patch
Type: text/x-diff
Size: 9780 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20040809/a4b80303/attachment-0001.patch>


More information about the xorg mailing list