The KDE 5 tests on Hydra regularly time-out due to KDE 5 applications being so slow. This is mainly due to searching so many paths in XDG_DATA_DIRS, as @edolstra pointed out here. I thought it would be more appropriate to open a ticket for this issue because it has come up in different contexts. Let me review the problem itself and possible solutions.
Cause
This problem affects all KDE 5 applications, but the application in particular which triggered this issue was Dolphin, so I will address it specifically. Dolphin is slow because loading icons requires searching every directory in XDG_DATA_DIRS for icons. Dolphin renders many icons, so this issue hits harder than other applications. kdeWrapper adds many paths to this list so that Dolphin and all the libraries it depends on may find their runtime dependencies. The wrapper allows the dependencies to be resolved whether the application is installed in the user or the system profile and it allows the application to run cleanly from the Nix store. It is also necessary to allow installation of applications depending on different versions of KDE Frameworks or even Qt.
Solution (-1): symlink farming
Until recently, kdeWrapper worked by creating a symlink farm for all the runtime dependencies and adding that path to XDG_DATA_DIRS. This is theoretically nice: a filesystem is a tree, so this basically amounts to creating a lookup tree for all the runtime dependencies. The problem is, every symlink takes up one filesystem block; at 4 KB each, that adds up. As @edolstra pointed out in #20433, this can add up to ~50 MB per application and up to ~400 MB for a typical KDE 5 installation. This is obviously unacceptable!
Solution 0: KDE unwrapped
If we remove the wrappers and resort to propagatedUserEnvPkgs, we gain the speed of symlink farming without the overhead. However, it will no longer be possible to run KDE 5 applications from the Nix store. As @abbradar pointed out, this will resurrect the long-standing problem of Qt applications "poisoning" the system against applications using other Qt versions. As a result, it will probably be impossible to install KDE 5 applications using nix-env. It will also break KDE 5 applications running outside of KDE, except by an obscure workaround.
Solution 1: dynamic symlink farming
The problem with symlink farming is the filesystem block occupied by each symlink. Placing the symlinks on a block-less filesystem like tmpfs removes this overhead! This would require creating the symlink farm dynamically. That is non-negligible overhead, but in principle it only needs to be done once per store path per boot, so it may be an acceptable compromise. Unfortunately, it would be a security nightmare: it would essentially be possible for a non-privileged user to modify the XDG_DATA_DIRS of any running application at any time!
Since the only remotely-acceptable solution on this list is "just let KDE be slow," I'm open to any suggestions!
The KDE 5 tests on Hydra regularly time-out due to KDE 5 applications being so slow. This is mainly due to searching so many paths in
XDG_DATA_DIRS, as @edolstra pointed out here. I thought it would be more appropriate to open a ticket for this issue because it has come up in different contexts. Let me review the problem itself and possible solutions.Cause
This problem affects all KDE 5 applications, but the application in particular which triggered this issue was Dolphin, so I will address it specifically. Dolphin is slow because loading icons requires searching every directory in
XDG_DATA_DIRSfor icons. Dolphin renders many icons, so this issue hits harder than other applications.kdeWrapperadds many paths to this list so that Dolphin and all the libraries it depends on may find their runtime dependencies. The wrapper allows the dependencies to be resolved whether the application is installed in the user or the system profile and it allows the application to run cleanly from the Nix store. It is also necessary to allow installation of applications depending on different versions of KDE Frameworks or even Qt.Solution (-1): symlink farming
Until recently,
kdeWrapperworked by creating a symlink farm for all the runtime dependencies and adding that path toXDG_DATA_DIRS. This is theoretically nice: a filesystem is a tree, so this basically amounts to creating a lookup tree for all the runtime dependencies. The problem is, every symlink takes up one filesystem block; at 4 KB each, that adds up. As @edolstra pointed out in #20433, this can add up to ~50 MB per application and up to ~400 MB for a typical KDE 5 installation. This is obviously unacceptable!Solution 0: KDE unwrapped
If we remove the wrappers and resort to
propagatedUserEnvPkgs, we gain the speed of symlink farming without the overhead. However, it will no longer be possible to run KDE 5 applications from the Nix store. As @abbradar pointed out, this will resurrect the long-standing problem of Qt applications "poisoning" the system against applications using other Qt versions. As a result, it will probably be impossible to install KDE 5 applications usingnix-env. It will also break KDE 5 applications running outside of KDE, except by an obscure workaround.Solution 1: dynamic symlink farming
The problem with symlink farming is the filesystem block occupied by each symlink. Placing the symlinks on a block-less filesystem like tmpfs removes this overhead! This would require creating the symlink farm dynamically. That is non-negligible overhead, but in principle it only needs to be done once per store path per boot, so it may be an acceptable compromise. Unfortunately, it would be a security nightmare: it would essentially be possible for a non-privileged user to modify the
XDG_DATA_DIRSof any running application at any time!Since the only remotely-acceptable solution on this list is "just let KDE be slow," I'm open to any suggestions!