]> pere.pagekite.me Git - homepage.git/blob - blog/data/2012-04-06-skolelinux-slowkdenfs.txt
Generated.
[homepage.git] / blog / data / 2012-04-06-skolelinux-slowkdenfs.txt
1 Title: Why the KDE menu is slow when /usr/ is NFS mounted - and a workaround
2 Tags: english, debian edu
3 Date: 2012-04-06 22:40
4
5 <p>Recently I have spent time with
6 <a href="http://www.slxdrift.no/">Skolelinux Drift AS</a> on speeding
7 up a <a href="http://www.skolelinux.org/">Debian Edu / Skolelinux</a>
8 Lenny installation using LTSP diskless workstations, and in the
9 process I discovered something very surprising. The reason the KDE
10 menu was responding slow when using it for the first time, was mostly
11 due to the way KDE find application icons. I discovered that showing
12 the Multimedia menu would cause more than 20 000 IP packages to be
13 passed between the LTSP client and the NFS server. Most of these were
14
15 NFS LOOKUP calls, resulting in a NFS3ERR_NOENT response. Because the
16 ping times between the client and the server were in the range 2-20
17 ms, the menus would be very slow. Looking at the strace of kicker in
18 Lenny (or plasma-desktop i Squeeze - same problem there), I see that
19 the source of these NFS calls are access(2) system calls for
20 non-existing files. KDE can do hundreds of access(2) calls to find
21 one icon file. In my example, just finding the mplayer icon required
22 around 230 access(2) calls.</p>
23
24 <p>The KDE code seem to search for icons using a list of icon
25 directories, and the list of possible directories is large. In
26 (almost) each directory, it look for files ending in .png, .svgz, .svg
27 and .xpm. The result is a very slow KDE menu when /usr/ is NFS
28 mounted. Showing a single sub menu may result in thousands of NFS
29 requests. I am not the first one to discover this. I found a
30 <a href="https://bugs.kde.org/show_bug.cgi?id=211416">KDE bug report
31 from 2009</a> about this problem, and it is still unsolved.</p>
32
33 <p>My solution to speed up the KDE menu was to create a package
34 kde-icon-cache that upon installation will look at all .desktop files
35 used to generate the KDE menu, find their icons, search the icon paths
36 for the file that KDE will end up finding at run time, and copying the
37 icon file to /var/lib/kde-icon-cache/. Finally, I add symlinks to
38 these icon files in one of the first directories where KDE will look
39 for them. This cut down the number of file accesses required to find
40 one icon from several hundred to less than 5, and make the KDE menu
41 almost instantaneous. I'm not quite sure where to make the package
42 publicly available, so for now it is only available on request.</p>
43
44 <p>The bug report mention that this do not only affect the KDE menu
45 and icon handling, but also the login process. Not quite sure how to
46 speed up that part without replacing NFS with for example NBD, and
47 that is not really an option at the moment.</p>
48
49 <p>If you got feedback on this issue, please let us know on debian-edu
50 (at) lists.debian.org.</p>
51
52 <p>Update 2015-08-04: The
53 <a href="http://anonscm.debian.org/cgit/debian-edu/upstream/kde-icon-cache.git/">source
54 of the scripts and associated Debian package</a> is available from the
55 Debian Edu github repository.</p>