stdenv/problems: only run problem if it's not ignored#519600
Merged
Conversation
b084faf to
6efe36a
Compare
6efe36a to
fbf56c5
Compare
fbf56c5 to
5964033
Compare
Review dismissed automatically
c2883e1 to
b5921c0
Compare
Member
|
Huh, interesting! Can you add a new test for this? See the top of problems.nix for how to run them |
3219e64 to
317cb76
Compare
Contributor
Author
|
Done. Also edited the PR description to clarify the reasoning and logic. |
55dc877 to
52b07e5
Compare
d52b393 to
3724f3d
Compare
The stats may be lying to me when they say that this saves 1.86% of attrset lookups, and `?` may just not be accurately tracked. But at worst, performance will stay the same, since the check will fail for all non-broken packages. And who knows, maybe it does help, by nature of not checking the value!
kind and name are more likely to stay the same. Doing this allows us to cache the kind and name when calling the handler for a problem.
A package failing an automatic problem (of which there's currently only one) is rare. A package having meta.problems specified is even rarer. Inlining the getName call to its two usages saves a thunk in the vast, vast majority of cases, and I consider it to be worth it.
abad434 to
85e32af
Compare
12 tasks
infinisil
reviewed
Jun 16, 2026
Member
There was a problem hiding this comment.
A bit late with the review, but this is great! I tried to get the performance impact as low as possible in the PR that implemented meta.problems (#338267) compared to the original (#177272), but the optimisation here didn't occur to me, so thank you!
I checked out the code as well, no complaints to be found there :)
13 tasks
Contributor
|
Successfully created backport PR for |
2 tasks
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.
The problems system was designed with an oversight - this bit of code:
calls
problem.conditionon every problem, before checking if the problem is ignored. This is specifically meaningful in a nixpkgs context, becausemaintainerlessis not on by default, but it is inautomaticProblems. This makes every package check that it has nonempty maintainers when it doesn't have to. What's more, packages with empty maintainers have to callhandlerForProblemunnecessarily, which allocates memory, calls some primops, and requires several function calls.I originally just tried swapping the order of the conditions - but this made things a lot worse, since it now ran
handlerForProblem(with its own overhead) on non-broken packages. Instead, I filter the problems to only those that that are defined and non-ignored. This checks bothproblems.matchersandproblems.config, while being a constant-time operation only done once.In the future, I hope to make
handlerForProblemless punishing. As it stands, the function performs a lot of unnecessary logic on every single derivation, when it has all of the data ahead of time, and could do much less.Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.