Fix legacyPackages performance#423290
Merged
roberth merged 2 commits intoNixOS:masterfrom Jul 13, 2025
Merged
Conversation
No change in behavior. By factoring this out, we can pass an extra overlay in addition to the impure ones in callers.
This saves the construction of an unused `pkgs` attrset and all that
is required to reach that, which is not a lot, but still significant.
Benchmark 1: nix eval .?ref=42608bc8e65c5bf596d6155ad2f0ded6253b1e69#hello.outPath --no-eval-cache
Time (mean ± σ): 1.062 s ± 0.011 s [User: 0.674 s, System: 0.226 s]
Range (min … max): 1.040 s … 1.080 s 10 runs
Benchmark 2: nix eval .?ref=8a7e18b270cb2256a0526b9cda1d9e410aacd440#hello.outPath --no-eval-cache
Time (mean ± σ): 1.317 s ± 0.033 s [User: 0.835 s, System: 0.270 s]
Range (min … max): 1.282 s … 1.371 s 10 runs
Summary
nix eval .?ref=42608bc8e65c5bf596d6155ad2f0ded6253b1e69#hello.outPath --no-eval-cache ran
1.24 ± 0.03 times faster than nix eval .?ref=8a7e18b270cb2256a0526b9cda1d9e410aacd440#hello.outPath --no-eval-cache
(where 42608bc had the same tree as this commit)
7ff3f04 to
b78a8c9
Compare
Member
|
|
Member
Author
|
The eval performance comparison uses the stable CLI, not flakes, so those times won't improve; they're already good in this regard. Also that p value seems way too low, probably because it's measuring the wrong thing. |
arianvp
approved these changes
Jul 13, 2025
Member
Author
|
Thank you Arian! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove one
pkgsconstruction.This makes
.#hello.outPath1.24 ± 0.03 times faster to evaluate.Larger closures will see a less dramatic effect. Expect a 100 to 300 ms improvement, depending on hardware etc.
(I don't like the impurities which are now more visible, but not they're not new; just preserved. Presumably they're used with
--impure, and I'd like to call that OT because unchanged. I don't like the alteredlibeither.)Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.