Bernardo Meurer Costa
|
18ec3d1094
|
libstore: Avoid copying derivations to the store if they are already valid
This avoids the quite costly copying of derivations to the daemon over the
wire in case it already exists in the eval store.
For a fresh instantiatation (after running nix-collect-garbage) this doesn't
significantly slow down eval:
taskset -c 2,3 hyperfine --reference "result-old/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket" --prepare "nix-collect-garbage --store /tmp/store1111 --no-keep-derivations" "result/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket"
Benchmark 1: result-old/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket
Time (mean ± σ): 388.7 ms ± 10.5 ms [User: 157.0 ms, System: 61.3 ms]
Range (min … max): 379.4 ms … 415.9 ms 10 runs
Benchmark 2: result/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket
Time (mean ± σ): 389.2 ms ± 4.8 ms [User: 158.5 ms, System: 60.7 ms]
Range (min … max): 381.2 ms … 397.6 ms 10 runs
But if the derivations are already instantiated this shows a pretty neat speedup:
taskset -c 2,3 hyperfine --reference "result-old/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket" "result/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket"
Benchmark 1: result-old/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket
Time (mean ± σ): 240.4 ms ± 3.1 ms [User: 148.1 ms, System: 57.0 ms]
Range (min … max): 233.8 ms … 245.0 ms 12 runs
Benchmark 2: result/bin/nix eval -f ../nixpkgs hello --store unix:///tmp/nix_socket
Time (mean ± σ): 226.5 ms ± 4.5 ms [User: 147.8 ms, System: 55.2 ms]
Range (min … max): 214.0 ms … 231.2 ms 13 runs
Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
|
2025-10-13 01:59:38 +03:00 |
|