Skip to content

Improve readDir performance #7314

@roberth

Description

@roberth

Is your feature request related to a problem? Please describe.

builtins.readDir currently performs stat calls for each directory entry. This is bad enough that @aakropotkin works around readDir with a generated file. A fast readDir may allow Nixpkgs to replace all-packages.nix over time; a project that the Nixpkgs Architecture Team is researching.

Describe the solution you'd like

Implementation 1, posix compatible:
Fill the attrset with thunks that call pathType #3096

Implementation 2, linux optimized:
Use getdents or getdents64

Describe alternatives you've considered

Avoid readDir on large directories, generate a list of files. The readDir function is not crucial for the architecture team proposal.

Additional context

nixpkgs-architecture/simple-package-paths#17 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions