mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
As it turns out using `std::regex` is actually the bottleneck for root discovery. Just substituting `std::` -> `boost::` makes root discovery twice as fast (3x if counting only userspace time). Some rather ad-hoc measurements to motivate the switch: (On master) ``` nix build github:nixos/nix/1e822bd4149a8bce1da81ee2ad9404986b07914c#nix-cli --out-link result-1e822bd4149a8bce1da81ee2ad9404986b07914c taskset -c 2,3 hyperfine "result-1e822bd4149a8bce1da81ee2ad9404986b07914c/bin/nix store gc --dry-run --max 0" Benchmark 1: result-1e822bd4149a8bce1da81ee2ad9404986b07914c/bin/nix store gc --dry-run --max 0 Time (mean ± σ): 481.6 ms ± 3.9 ms [User: 336.2 ms, System: 142.0 ms] Range (min … max): 474.6 ms … 487.7 ms 10 runs ``` (After this patch) ``` taskset -c 2,3 hyperfine "result/bin/nix store gc --dry-run --max 0" Benchmark 1: result/bin/nix store gc --dry-run --max 0 Time (mean ± σ): 254.7 ms ± 9.7 ms [User: 111.1 ms, System: 141.3 ms] Range (min … max): 246.5 ms … 281.3 ms 10 runs ``` `boost::regex` is a drop-in replacement for `std::regex`, but much faster. Doing a simple before/after comparison doesn't surface any change in behavior: ``` result/bin/nix store gc --dry-run -vvvvv --max 0 |& grep "got additional" | wc -l result-1e822bd4149a8bce1da81ee2ad9404986b07914c/bin/nix store gc --dry-run -vvvvv --max 0 |& grep "got additional" | wc -l ``` |
||
---|---|---|
.. | ||
build-remote | ||
external-api-docs | ||
internal-api-docs | ||
libcmd | ||
libexpr | ||
libexpr-c | ||
libexpr-test-support | ||
libexpr-tests | ||
libfetchers | ||
libfetchers-c | ||
libfetchers-tests | ||
libflake | ||
libflake-c | ||
libflake-tests | ||
libmain | ||
libmain-c | ||
libstore | ||
libstore-c | ||
libstore-test-support | ||
libstore-tests | ||
libutil | ||
libutil-c | ||
libutil-test-support | ||
libutil-tests | ||
nix | ||
nix-build | ||
nix-channel | ||
nix-collect-garbage | ||
nix-copy-closure | ||
nix-env | ||
nix-instantiate | ||
nix-store | ||
perl | ||
nix-functional-tests | ||
nix-manual |