Repository navigation
Description
I'm writing this as "umbrella"/mega/tracking issue in order to address entire nixos ecosystem. the content will be modified frequently.
The /nix/store is fragmented into many sparse directories, with resources like shared libraries and plug-ins normally linked via search paths in environment variables1 or ELF headers2. Search paths usually consist of directories and are scanned sequentially on every look-up (e.g. every dlopen in case of shared objects).
This results in applications making excessive filesystem calls (more than O(n), normally O(n^2) in n the number of dependencies), resulting in spam of stat/openat-like syscalls ("stat storm"), 90% returning ENOENT/EINVAL.
This cost may be seen as trivial for high-end workstations with local file systems. "Stat storm" and sparse access pattern may, however, be significant:
- for low-power hardware (laptops, mobile, edge), causing startup delays exceeding 4 seconds even in battery balanced preset,3
- with
/nix/storedeployed on network file systems (NFS, Lustre), e.g. in HPC clusters.
Background
I (ilsubyeega) have been personally tracking this issue since KDE Plasma environment was slow4, and found out that it has a lot of syscalls to load each resources. I'm using a desktop right now, so i could ignore this, but soon I must use laptop while staying at univ. This didn't happen for me when using Arch which is FHS-compliant distro few years ago before switching to NixOS. Today I became aware of past discussions(2016) and started writing about this because it has not been actively discussed recent.
References
- Prior research and extensive discussions include:
- Guix's
ld.so.cachealso attempted in Speed up application startup by usingld.so.cache#207061 pennae's per-DSO ld cache draft: per-dso .so resolution cache on glibc #207893fzakaria's shrinkwrap and follow-ups:- https://github.com/fzakaria/shrinkwrap,
- https://github.com/fzakaria/nix-harden-needed,
- "Mapping Out the HPC Dependency Chaos", https://arxiv.org/abs/2211,
- "Breaking apart the Shared Object Monolith", https://github.com/NixOS/nixpkgs/files/10274134/Breaking_Apart_the_Shared_Object_Monolith.pdf.
- Guix's
- RFC may cover some portions about this (2025): [RFC 0189] Contracts rfcs#189
- Related or potentially related issues: KDE 5 applications are slow #21345 Link dynamic libraries more granularly to Java #21676 Link to libraries through absolute paths? #24844 Excessively long environment variables in kde plasma #126590 Speed up application startup by using
ld.so.cache#207061 KDE applications are slow in Plasma #363068 Remove patchelf from stdenv #362353 RFC: Slow dynamic linker resolution of shared libraries #367683 - EDIT(SomeoneSerge): an intrinsically related problem is ld.so priorities, the "overriding of services", RPATH-vs-RUNPATH, and late-vs-early-binding, including the linking of drivers, interaction of different versions of ld.so: [WIP] binutils, build-fhs-userenv: make use of ld fallback #59595 (comment), glibc: implement
LD_FALLBACK_PATHenvironment variable #248547,ImportErrorwhen running a Python package that includes share libraries cachix/devenv#773, Build against an older libc, keep the newest in the runtime closure #303405, glibc: add NIX_LD_LIBRARY_PATH #31263, ld-audit-search-mod: init at 0-unstable-2025-06-19 #418244.
Some scenarios
WIP. This is not a complete list of scenarios, Going to post later when i got time and will update when found new scenarios.
strace -f dolphin |& tee out
cat out | grep -F .so | wc -l
# results 4954 (loading libraries via ld and also qt's plugin)
cat out | grep -F qt.qm | wc -l
# results 7576Fontconfig overhead
Adding more fonts makes significantly more loading time. some programs like coppwr do not affect from this as it seems to use static font (by embedded?). The log below is running strace and line counts when installed 20 fonts in nixos system(home manager installed but its configured at nixos side).
strace -f zeditor |& tee out
cat out | grep fontconfig | grep EINVAL | wc -l
# results 318 items
cat out | grep fonts | wc -l
# results 2539 items
rm out
strace -f dolphin |& tee out
cat out | grep share/fonts | grep ENOENT | wc -l
# results 390Note
I believe there is no oneshot fix to mitigate these but it can satisfy some users which uses potato pc like me.
I use NixOS with home-manager, usually guis are installed in home-manager, just for sure.
Mention [email protected] on matrix if needed, i might able to chat.
From my knowledge, i can propose this issue by multiple preset (not much ideal):
- energy efficient: aggressive usage of link farming for low cpu and io usage when runtime, but it trades with build time and disk inode usage.
- storage efficient: rely on some custom dynamic linker or fs cache with negative cache support.
- more security: no changes from now, there is dedicated hardening NixOS documentation.
Footnotes
-
Environment variables like
XDG_DATA_DIRS,QT_PLUGIN_PATH,LD_LIBRARY_PATH. also wrapper feed these. ↩ -
Primarily
DT_RUNPATH. ↩ -
Thinkpad T14 Gen1 (Intel), i5-10210U, 16+32GB, samsung nvme ssd(evo), FDE. ↩
-
https://www.reddit.com/r/kde/comments/1h7xr5n/how_can_i_speed_up_of_launching_kdeqt_based/
KDE applications are slow in Plasma #363068 ↩
Activity
mightyiam commentedon Jan 22, 2026
Full Time Nix | Stable linking with Farid Zakaria
Add --build-resolution-cache to write a per-DSO library resolution note
Add --build-resolution-cache to write a per-DSO library resolution note
Add --build-resolution-cache to write a per-DSO library resolution note
Add --build-resolution-cache to write a per-DSO library resolution note
Add --build-resolution-cache to write a per-DSO library resolution note
Add --build-resolution-cache to write a per-DSO library resolution note
glibc: read a per-DSO resolution-cache note and generate it by default
glibc: read a per-DSO resolution-cache note and generate it by default
nixos-discourse commentedon Jun 26, 2026
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/making-devenv-start-fast-and-the-whole-nixpkgs-with-it/78594/1
glibc: read a per-DSO resolution-cache note and generate it by default
ilsubyeega commentedon Jun 28, 2026
fwiw might like experimenting for retriving ground truths, what if program is wrapped/sandboxed with no bloats, like user's envs(Qt plugins etc), fonts are installed in single directory etc, then startup time etc.
glibc: read a per-DSO resolution-cache note and generate it by default
glibc: read a per-DSO resolution-cache note and generate it by default
glibc: read a per-DSO resolution-cache note and generate it by default
glibc: read a per-DSO resolution-cache note and generate it by default
nixos-discourse commentedon Jul 14, 2026
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/error-loading-libstdc-so-6/78934/4
glibc: read a per-DSO resolution-cache note and generate it by default