KDE System Administration/Caches: Difference between revisions

From KDE TechBase
(Add documentation for administrators about KDE Caches)
 
(Replaced content with "{{Moved To Userbase}}")
 
Line 1: Line 1:
=System Caches=
{{Moved To Userbase}}
There are several caches for KDE data that are created when they are
first needed. Especially in setups where there is no persistent
HOME directory available or where NFS is used, the creation of the
caches can considerably increase the time it takes after login
until the Desktop session becomes usable.
 
This page is intended to give an overview of the existing caches and
provide tips on how to improve the caching behavior in your setup.
 
== General ==
Caches are placed by default into /var/tmp/kdecache-<username> and
a symlink pointing to that cache is placed in the KDEHOME directory
under cache-<hostname>. You can move that loctation by modifing the
[http://techbase.kde.org/KDE_System_Administration/Environment_Variables#KDEVARTMP KDEVARTMP]
environment variable.
 
All caches are memory mapped at startup to improve perfomance when
their contents are accessed. Each user needs is own cache with write
access to it.
 
=== KSycoca ===
KSycoca is the "KDE SYstem COnfiguration CAche". It contains a binary
representation of the various .desktop files that provide information
about installed software and services and which default applications
should be used. (See [http://techbase.kde.org/KDE_System_Administration/XDG_Filesystem_Hierarchy
XDG_Filesystem_Hierarchy] for more information about desktop files.
Due to the potential number of desktop files and locations where
the desktop files can be stored rebuilding the KSycoca cache can take
a while, especially if your /usr directory is mounted on a Network
File System.
 
To check how long this takes on your system you can trigger a full rebuild
of the KSycoca database by executing:
    kbuildsycoca4  --noincremental
 
 
=== Icon Cache ===
The icon cache is used to store the decompressed pixmaps of used icons so
that they can be shared in multiple applications.
Although the icon cache does not considerably affect the time it takes
for the KDE Desktop to become available after login, it can create
a bad user experience when after a long login the users finally
opens an icon intensive application like the Start Menu as this
will again result in a large number of system calls to find the
best size of an icon in various locations.
 
=== Plasma Cache ===
The plasma cache is the largest of the caches when you use Plasma
Desktop. But again this contains mostly decompressed Pixmaps of images
(like your wallpaper). As those pixmaps are transferred while they
are still compressed, persisting this cache on an NFS might even negatively
affect your performance.
 
=== Other Caches ===
There are some other caches used by various applications but those are
mostly small and do not considerably affect the performance of the
Desktop session as a whole.
 
 
== Using prepared caches to increase performance ==
To avoid rebuilding the KSycoca and the Icon cache for each new user
you can create an up to date cache for your system and copy it on
startup into the users cache directory. This will significantly reduce
the number of "open" system calls excuted when starting a KDE
Desktop session.
In a deployment where the start of a desktop session took ~80 seconds
the startup time could be reduced by this measure to ~50 seconds.
 
The downside is that you have to manually update this cache after installing
or updating new software.
 
To create your caches:
* Log in with a fresh user. Open the start menu, maybe start an often used application like dolphin.
* Copy the files: icon-cache.kcache kdesycoca4 and kdesycoca4stamp from the users cache directory to a globally readable folder e.g.: /var/cache/kde
* Set an environment variable pointing to the cache. You can do this with:
echo "export KDE_PREP_CACHE=/var/cache/kde" > /usr/share/env/global-cache.sh
(This will be sourced by the startkde script)
 
 
Then apply the following patch to your startkde script (or do something similar in there):
--- startkde.orig 2012-11-28 10:38:50.000000000 +0000
+++ startkde 2012-11-29 10:50:05.000000000 +0000
@@ -255,6 +255,28 @@
      fi
  done
 
+# Check if there are prepared caches and copy them to the
+# users location if he does not have any caches.
+# You can use this to speed up initial KDE startup times.
+if test -n "$KDE_PREP_CACHE"; then
+    cache_config_path=$(kde4-config --path cache)
+    if test -f "${KDE_PREP_CACHE}/icon-cache.kcache"; then
+        cp -u --preserve=timestamps "${KDE_PREP_CACHE}/icon-cache.kcache" "${cache_config_path}/icon-cache.kcache"
+        touch ${cache_config_path}/global_icon_cache_used
+    fi
+    if test -f "${KDE_PREP_CACHE}/ksycoca4" -a "${KDE_PREP_CACHE}/ksycoca4stamp"; then
+        if test -n "${KDESYCOCA}"; then
+            cp -u --preserve=timestamps "${KDE_PREP_CACHE}/ksycoca4" "${KDESYCOCA}"
+            cp -u --preserve=timestamps "${KDE_PREP_CACHE}/ksycoca4stamp" "${KDESYCOCA}stamp"
+            touch ${cache_config_path}/global_sycoca_used
+        else
+            cp -u --preserve=timestamps "${KDE_PREP_CACHE}/ksycoca4" "${cache_config_path}"
+            cp -u --preserve=timestamps "${KDE_PREP_CACHE}/ksycoca4stamp" "${cache_config_path}"
+            touch ${cache_config_path}/global_sycoca_used
+        fi
+    fi
+fi
+
  # In case of dcop sockets left by a previous session, cleanup
  #dcopserver_shutdown

Latest revision as of 13:18, 11 March 2016

This page is now on the Userbase wiki.