Skip to content

Address /nix/store recursive lookup/syscall overhead #481620

Open

Description

@ilsubyeega

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/store deployed 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

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 7576

Fontconfig 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 390

Note

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

  1. Environment variables like XDG_DATA_DIRS, QT_PLUGIN_PATH, LD_LIBRARY_PATH. also wrapper feed these. ↩

  2. Primarily DT_RUNPATH. ↩

  3. Thinkpad T14 Gen1 (Intel), i5-10210U, 16+32GB, samsung nvme ssd(evo), FDE. ↩

  4. 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

  1. mightyiam commented on Jan 22, 2026

    @mightyiam
    Member
  2. added
    0.kind: enhancement
    1.severity: significant
    5.scope: tracking
    on May 19, 2026
  3. nixos-discourse commented on Jun 26, 2026

    @nixos-discourse
  4. ilsubyeega commented on Jun 28, 2026

    @ilsubyeega
    ContributorAuthor

    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.

  5. nixos-discourse commented on Jul 14, 2026

    @nixos-discourse

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: enhancement1.severity: significant5.scope: tracking

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions