forked from mirrors/nixpkgs
stdenv: Avoid allocating intermediate attrset when checking meta validity
This is a small performance optimization. It should be impercetible to most. Benchmarks: - Before ``` json { "cpuTime": 0.2777960002422333, "envs": { "bytes": 3832648, "elements": 189513, "number": 144784 }, "gc": { "heapSize": 402915328, "totalBytes": 50229344 }, "list": { "bytes": 655304, "concats": 3249, "elements": 81913 }, "nrAvoided": 218962, "nrFunctionCalls": 127718, "nrLookups": 40946, "nrOpUpdateValuesCopied": 1563978, "nrOpUpdates": 8542, "nrPrimOpCalls": 113032, "nrThunks": 329605, "sets": { "bytes": 29774864, "elements": 1824537, "number": 36392 }, "sizes": { "Attr": 16, "Bindings": 16, "Env": 16, "Value": 24 }, "symbols": { "bytes": 235909, "number": 24432 }, "values": { "bytes": 9691392, "number": 403808 } } ``` - After ``` { "cpuTime": 0.2615779936313629, "envs": { "bytes": 3833832, "elements": 189661, "number": 144784 }, "gc": { "heapSize": 402915328, "totalBytes": 50212960 }, "list": { "bytes": 655304, "concats": 3249, "elements": 81913 }, "nrAvoided": 218814, "nrFunctionCalls": 127718, "nrLookups": 40798, "nrOpUpdateValuesCopied": 1563978, "nrOpUpdates": 8542, "nrPrimOpCalls": 113032, "nrThunks": 329457, "sets": { "bytes": 29765392, "elements": 1824093, "number": 36244 }, "sizes": { "Attr": 16, "Bindings": 16, "Env": 16, "Value": 24 }, "symbols": { "bytes": 235909, "number": 24432 }, "values": { "bytes": 9687840, "number": 403660 } } ```
This commit is contained in:
parent
7d6c3583af
commit
9a0a097a94
|
@ -479,16 +479,21 @@ let
|
|||
|
||||
assertValidity = { meta, attrs }: let
|
||||
validity = checkValidity attrs;
|
||||
in validity // {
|
||||
inherit (validity) valid;
|
||||
in validity // {
|
||||
# Throw an error if trying to evaluate a non-valid derivation
|
||||
# or, alternatively, just output a warning message.
|
||||
handled =
|
||||
{
|
||||
no = handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; };
|
||||
warn = handleEvalWarning { inherit meta attrs; } { inherit (validity) reason errormsg; };
|
||||
yes = true;
|
||||
}.${validity.valid};
|
||||
|
||||
(
|
||||
if valid == "yes" then true
|
||||
else if valid == "no" then (
|
||||
handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; }
|
||||
)
|
||||
else if valid == "warn" then (
|
||||
handleEvalWarning { inherit meta attrs; } { inherit (validity) reason errormsg; }
|
||||
)
|
||||
else throw "Unknown validitiy: '${valid}'"
|
||||
);
|
||||
};
|
||||
|
||||
in { inherit assertValidity commonMeta; }
|
||||
|
|
Loading…
Reference in a new issue