Repository navigation
lib.modules: further performance cleanups - #583020
Merged
Merged
Conversation
Saves unnecessary function calls, since args are always constant.
Previously, we would always call `pushDownProperties` recursively - but now we only do it if the second layer also needs to be pushed. Saves a `map` and a function call on each definition.
6 of 8 tasks
philiptaron
requested changes
Nov 4, 2026
philiptaron
left a comment
Contributor
There was a problem hiding this comment.
Fully human review.
- d9cbd05 - LGTM, would use a prime instead of inlining
- 855f47f - LGTM, can go farther here by using genList instead of imap (for future)
- d9a395e - LGTM
- e2b35cb - LGTM after some staring
- cfffa65 - LGTM, nice win for readability
- 7e30e5e - LGTM, this "let binding for readability" is so nice but it harms the env and thunk counts due to where textually it is defined. I wish that the evaluator didn't have this property.
- 4c38714 - ❌ - there's an error regression here. I also didn't like this inlining. I (rather than claude) took a stab at it in 916f1a4, ba3e857, and 9d70e5b stacked on top of 7e30e5e. At least in Nix 2.35
inherit (x) yin an attrset is worse thany = x.ydue to an additional env. - a1d9b0d - nice win
- fe0374e - nice win
- d2a2a92 - hate that this is a win, LGTM
- 7f67de7 - LGTM
- 750b7c2 - LGTM
❌ on the review solely for the error prefix regression. You can cherry-pick or not the commits for the alternate path.
We could probably drop this at some point in the future - but for now, inlining it prevents the need to iterate again.
We inline other similar functions within this file, and this is a key improvement for some contexts.
llakala
force-pushed
the
lib-modules-cleanups
branch
from
November 4, 2026 21:14
750b7c2 to
40440ef
Compare
Contributor
Author
Can reproduce - ew. cc @xokdvium - is the last commit saving thunks just an artifact of NIX_SHOW_STATS, or does nix allocate a thunk for
I'm struggling to get my head around how your alternate version of saving the
Thanks :) |
philiptaron
approved these changes
Nov 4, 2026
Contributor
Author
|
Thanks! |
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.
Just going through with my brain, NIX_SHOW_STATS, and an untrustworthy profiler. All
lib/modulestests pass.Stats diff for my own config:
{ "attrset": { "lookups": "-1.58%", "merges": "-6.07%", "mergeCopies": "-0.95%" }, "list": { "concats": "-14.09%" }, "parser": { "expressions": "+0%" }, "memoryBytes": { "envs": "-6.15%", "list": "-0.88%", "sets": "-1.83%", "symbols": "+0%", "values": "-3.82%", "total": "-3.2%" }, "speed": { "primops": "-7.01%", "functionCalls": "-7.97%", "thunksMade": "-4.82%", "thunksAvoided": "-5.71%" } }Of course, most of this is fluff. But my wall-time-evaluation goes from 4.923s to 4.883s (averaged with hyperfine over ten runs, for a 0.91% improvement).
I'd politely ask that reviewers post their own thoughts, rather than responding with whatever Claude says. If you must use an LLM, I can't stop you - but I ask that you do it in a separate PR.
Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.