Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileset.fileFilter: Don't run predicate unnecessarily #267381

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

infinisil
Copy link
Member

@infinisil infinisil commented Nov 14, 2023

Description of changes

Before:

nix-repl> :a lib.fileset

nix-repl> trace (fileFilter (file: builtins.trace file.name false) ./default.nix)
trace: README.md
trace: benchmark.sh
trace: default.nix
trace: internal.nix
trace: mock-splitRoot.nix
trace: tests.sh

After:

nix-repl> trace (fileFilter (file: builtins.trace file.name false) ./default.nix)
trace: default.nix

Note that even if the filter returned true before, the files weren't added to the store, so this is just a performance and laziness improvement and arguably not a bug fix.

This work is sponsored by Antithesis

Things done

  • Cleaned up surrounding code
  • Added tests

Before:

    nix-repl> fileset.trace (fileset.fileFilter (file: builtins.trace file.name false) ./default.nix)
    trace: README.md
    trace: benchmark.sh
    trace: default.nix
    trace: internal.nix
    trace: mock-splitRoot.nix
    trace: tests.sh

After:

    nix-repl> fileset.trace (fileset.fileFilter (file: builtins.trace file.name false) ./default.nix)
    trace: default.nix
@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label Nov 14, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Nov 14, 2023
@infinisil infinisil merged commit 7e533ba into NixOS:master Nov 15, 2023
@infinisil infinisil deleted the fileset.fileFilter-path branch November 15, 2023 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant