lorri icon indicating copy to clipboard operation
lorri copied to clipboard

`lorri direnv` extremely slow with a large number of env vars

Open mammothbane opened this issue 4 years ago • 0 comments

Describe the bug Very high evaluation times for output of lorri direnv with a large number of environment variables. In this example repo, I generate 2000 env vars and the eval takes 10-15s. I.e., every time you enter the repo directory, the shell is nonfunctional for 10-15s. There is a similar amount of overhead every time a change happens -> a nix build occurs.

This overhead is somehow linked to lorri — direnv using eval $(nix print-dev-env) instead of eval $(lorri direnv) takes on the order of a second to complete.

To Reproduce

  • Clone my example repo.
  • direnv allow, let lorri build
  • cd out of/back into the repo dir -- takes on the order of 10-15s for me
  • journalctl --user -eu lorri confirms that this slowness isn't because any nix builds have taken place.

For more quantitative results, from the parent directory of lorri-slow:

  • time direnv exec lorri-slow true
    • on my machine: 14.92s user 0.17s system 99% cpu 15.127 total
  • time nix-shell lorri-slow/shell.nix --run true
    • on my machine: 0.49s user 0.10s system 95% cpu 0.622 total

Expected behavior lorri direnv to finish evaluating in well under a second if not waiting on nix to build.

Metadata

$ lorri info --shell-file shell.nix
lorri version: 1.2
GC roots exist, shell_gc_root: <elided>
$ uname -a
Linux <hostname elided> 5.4.85 #1-NixOS SMP Mon Dec 21 12:27:07 UTC 2020 x86_64 GNU/Linux

mammothbane avatar Jan 26 '21 12:01 mammothbane