mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
optimize derivation string parsing
a bunch of derivation strings contain no escape sequences. we can optimize for this fact by first scanning for the end of a derivation string and simply returning the contents unmodified if no escape sequences were found. to make this even more efficient we can also use BackedStringViews to avoid copies, avoiding heap allocations for transient data. before: Benchmark 1: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 6.952 s ± 0.015 s [User: 5.294 s, System: 1.452 s] Range (min … max): 6.926 s … 6.974 s 10 runs after: Benchmark 1: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 6.907 s ± 0.012 s [User: 5.272 s, System: 1.429 s] Range (min … max): 6.893 s … 6.926 s 10 runs
This commit is contained in:
parent
2cfc4ace35
commit
79d3d412ca
2 changed files with 48 additions and 23 deletions
6
doc/manual/rl-next/drv-string-parse-hang.md
Normal file
6
doc/manual/rl-next/drv-string-parse-hang.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
synopsis: Fix handling of truncated `.drv` files.
|
||||
prs: 9673
|
||||
---
|
||||
|
||||
Previously a `.drv` that was truncated in the middle of a string would case nix to enter an infinite loop, eventually exhausting all memory and crashing.
|
Loading…
Add table
Add a link
Reference in a new issue