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

nix-gitignore: Optimise performance #106172

Merged
merged 1 commit into from Dec 7, 2020

Conversation

adisbladis
Copy link
Member

@adisbladis adisbladis commented Dec 7, 2020

There are a few operations in this library that naively runs on every
iteration while they could be cached.

For a simple test repository with a small number of files and ~1000
gitignore patterns this brings memory usage down from ~233M to ~161M
and wall time from 2.6s down to 0.78s.

This should scale similarly with the number of files in a repository.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

cc @siers @andir

There are a few operations in this library that naively runs on every
iteration while they could be cached.

For a simple test repository with a small number of files and ~1000
gitignore patterns this brings memory usage down from ~233M to ~157M
and wall time from 2.6s down to 0.78s.

This should scale similarly with the number of files in a repository.
@adisbladis adisbladis merged commit db30be9 into NixOS:master Dec 7, 2020
@adisbladis
Copy link
Member Author

The equivalent PR was merged upstream, merging here too.

@kevincox
Copy link
Contributor

kevincox commented Dec 26, 2020

This appears to break negative patterns in some way. With this commit there are no files included where as in the parent commit the files are included as expected.

src = pkgs.nix-gitignore.gitignoreSource [
	"*"
	"!Gemfile*"
] ./.;

Since this is just a performance optimization should we revert now and debug later?

kevincox added a commit that referenced this pull request Jan 3, 2021
Reverts #106172 ef3ed45

This change causes issues with negative patterns. Reverting now until those can be resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants