1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 02:21:16 +02:00
nix/src
Sergei Zimmerman 3a1301cd6d
libstore: Use boost::regex for GC root discovery
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
```
2025-05-06 21:58:52 +00:00
..
build-remote treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
external-api-docs Format .nix files 2025-01-24 17:04:02 +01:00
internal-api-docs Format .nix files 2025-01-24 17:04:02 +01:00
libcmd Simplify RegisterCommand 2025-05-05 08:28:12 +02:00
libexpr Simplify RegisterPrimOp 2025-05-05 08:26:29 +02:00
libexpr-c Docs 2025-04-02 18:02:32 +02:00
libexpr-test-support Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
libexpr-tests libexpr: fix UB in builtins.ceil and builtins.floor 2025-04-13 04:36:09 +02:00
libfetchers Simplify registerInputScheme() 2025-05-05 08:35:59 +02:00
libfetchers-c nix-fetchers-c: Init with settings object 2025-04-02 18:29:42 +02:00
libfetchers-tests Drop fs alias in favour of std::filesystem 2025-05-01 14:24:34 +02:00
libflake treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
libflake-c Fix flake-c out of bounds access 2025-04-25 17:07:32 +02:00
libflake-tests nix-flake-c: Add lock flags 2025-04-02 18:29:42 +02:00
libmain treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
libmain-c Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
libstore libstore: Use boost::regex for GC root discovery 2025-05-06 21:58:52 +00:00
libstore-c Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
libstore-test-support Drop fs alias in favour of std::filesystem 2025-05-01 14:24:34 +02:00
libstore-tests libstore: Introduce WorkerProto::FeatureSet alias 2025-05-02 17:40:34 +00:00
libutil Fix windows warning 2025-05-06 15:02:10 -04:00
libutil-c Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
libutil-test-support Merge pull request #12877 from roberth/c-api-libflake-override-input 2025-04-08 09:01:51 +02:00
libutil-tests add DirectoryIterator to re-throw std::filesystem::filesystem_error 2025-05-01 11:54:13 +02:00
nix Simplify Implementations registration 2025-05-05 08:41:23 +02:00
nix-build treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
nix-channel Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
nix-collect-garbage Drop fs alias in favour of std::filesystem 2025-05-01 14:24:34 +02:00
nix-copy-closure Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
nix-env treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
nix-instantiate Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
nix-store Rename shellEscape -> escapeShellArgAlways 2025-04-23 22:56:07 +02:00
perl Merge pull request #12836 from NixOS/component-in-header-path 2025-04-02 15:29:22 +02:00
nix-functional-tests Build Functional tests with Meson 2024-08-14 15:35:40 -04:00
nix-manual Build the manual with Meson 2024-10-09 11:58:17 -04:00