From dc895fb2815032adbcc49f090812fa355074d9be Mon Sep 17 00:00:00 2001 From: pennae Date: Fri, 15 Oct 2021 16:30:58 +0200 Subject: [PATCH] lib: make extendDerivation lighter on eval the fix to extendDerivation in #140051 unwittingly worsened eval performance by quite a bit. set elements alone needed over 1GB extra after the change, which seems disproportionate to how small it was. if we flip the logic used to determine which outputs to install around and keep a "this one exactly" flag in the specific outputs instead of a "all of them" in the root we can avoid most of that cost. --- lib/attrsets.nix | 2 +- lib/customisation.nix | 5 ++--- pkgs/build-support/buildenv/default.nix | 2 +- pkgs/development/compilers/llvm/10/default.nix | 6 +++--- pkgs/development/compilers/llvm/11/default.nix | 8 ++++---- pkgs/development/compilers/llvm/12/default.nix | 6 +++--- pkgs/development/compilers/llvm/13/default.nix | 6 +++--- pkgs/development/compilers/llvm/5/default.nix | 8 ++++---- pkgs/development/compilers/llvm/6/default.nix | 8 ++++---- pkgs/development/compilers/llvm/7/default.nix | 8 ++++---- pkgs/development/compilers/llvm/8/default.nix | 8 ++++---- pkgs/development/compilers/llvm/9/default.nix | 8 ++++---- pkgs/development/compilers/llvm/git/default.nix | 6 +++--- 13 files changed, 40 insertions(+), 41 deletions(-) diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 31fddc59e20e..812521ce6d1c 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -487,7 +487,7 @@ rec { => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev" */ getOutput = output: pkg: - if pkg.outputUnspecified or false + if ! pkg ? outputSpecified || ! pkg.outputSpecified then pkg.${output} or pkg.out or pkg else pkg; diff --git a/lib/customisation.nix b/lib/customisation.nix index a794b673d70c..234a528527d3 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -145,14 +145,14 @@ rec { let outputs = drv.outputs or [ "out" ]; - commonAttrs = (removeAttrs drv [ "outputUnspecified" ]) // - (builtins.listToAttrs outputsList) // + commonAttrs = drv // (builtins.listToAttrs outputsList) // ({ all = map (x: x.value) outputsList; }) // passthru; outputToAttrListElement = outputName: { name = outputName; value = commonAttrs // { inherit (drv.${outputName}) type outputName; + outputSpecified = true; drvPath = assert condition; drv.${outputName}.drvPath; outPath = assert condition; drv.${outputName}.outPath; }; @@ -160,7 +160,6 @@ rec { outputsList = map outputToAttrListElement outputs; in commonAttrs // { - outputUnspecified = true; drvPath = assert condition; drv.drvPath; outPath = assert condition; drv.outPath; }; diff --git a/pkgs/build-support/buildenv/default.nix b/pkgs/build-support/buildenv/default.nix index c2186cf6bfa0..006fc2aff923 100644 --- a/pkgs/build-support/buildenv/default.nix +++ b/pkgs/build-support/buildenv/default.nix @@ -62,7 +62,7 @@ runCommand name # and otherwise use `meta.outputsToInstall`. The attribute is guaranteed # to exist in mkDerivation-created cases. The other cases (e.g. runCommand) # aren't expected to have multiple outputs. - (if drv.outputUnspecified or false + (if (! drv ? outputSpecified || ! drv.outputSpecified) && drv.meta.outputsToInstall or null != null then map (outName: drv.${outName}) drv.meta.outputsToInstall else [ drv ]) diff --git a/pkgs/development/compilers/llvm/10/default.nix b/pkgs/development/compilers/llvm/10/default.nix index 690328b26ae2..8bd7e937e7d7 100644 --- a/pkgs/development/compilers/llvm/10/default.nix +++ b/pkgs/development/compilers/llvm/10/default.nix @@ -63,14 +63,14 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; # disabled until recommonmark supports sphinx 3 #Llvm-manpages = lowPrio (tools.libllvm.override { diff --git a/pkgs/development/compilers/llvm/11/default.nix b/pkgs/development/compilers/llvm/11/default.nix index 9834ce30cdd2..ebd0dc672aa3 100644 --- a/pkgs/development/compilers/llvm/11/default.nix +++ b/pkgs/development/compilers/llvm/11/default.nix @@ -65,21 +65,21 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libllvm-polly = callPackage ./llvm { inherit llvm_meta; enablePolly = true; }; - llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; }; + llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; clang-polly-unwrapped = callPackage ./clang { inherit llvm_meta; diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index 388c7d95f69c..e68522faea06 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -66,14 +66,14 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; # disabled until recommonmark supports sphinx 3 #Llvm-manpages = lowPrio (tools.libllvm.override { diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index 9fd4cd98901d..13be73967143 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -68,14 +68,14 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libclang = callPackage ./clang { inherit llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; llvm-manpages = lowPrio (tools.libllvm.override { enableManpages = true; diff --git a/pkgs/development/compilers/llvm/5/default.nix b/pkgs/development/compilers/llvm/5/default.nix index 8205c67da77a..4593580b72fd 100644 --- a/pkgs/development/compilers/llvm/5/default.nix +++ b/pkgs/development/compilers/llvm/5/default.nix @@ -39,21 +39,21 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libllvm-polly = callPackage ./llvm { inherit llvm_meta; enablePolly = true; }; - llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; }; + llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; llvm-manpages = lowPrio (tools.libllvm.override { enableManpages = true; diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix index 7651b5ab13dc..9b1caf410bc2 100644 --- a/pkgs/development/compilers/llvm/6/default.nix +++ b/pkgs/development/compilers/llvm/6/default.nix @@ -39,21 +39,21 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libllvm-polly = callPackage ./llvm { inherit llvm_meta; enablePolly = true; }; - llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; }; + llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; llvm-manpages = lowPrio (tools.libllvm.override { enableManpages = true; diff --git a/pkgs/development/compilers/llvm/7/default.nix b/pkgs/development/compilers/llvm/7/default.nix index 6864353424f1..d014c043a80d 100644 --- a/pkgs/development/compilers/llvm/7/default.nix +++ b/pkgs/development/compilers/llvm/7/default.nix @@ -63,21 +63,21 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libllvm-polly = callPackage ./llvm { inherit llvm_meta; enablePolly = true; }; - llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; }; + llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; clang-polly-unwrapped = callPackage ./clang { inherit llvm_meta; diff --git a/pkgs/development/compilers/llvm/8/default.nix b/pkgs/development/compilers/llvm/8/default.nix index 34f204be3315..7252b75a3397 100644 --- a/pkgs/development/compilers/llvm/8/default.nix +++ b/pkgs/development/compilers/llvm/8/default.nix @@ -63,21 +63,21 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libllvm-polly = callPackage ./llvm { inherit llvm_meta; enablePolly = true; }; - llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; }; + llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; clang-polly-unwrapped = callPackage ./clang { inherit llvm_meta; diff --git a/pkgs/development/compilers/llvm/9/default.nix b/pkgs/development/compilers/llvm/9/default.nix index 8468fc363818..9126a614b106 100644 --- a/pkgs/development/compilers/llvm/9/default.nix +++ b/pkgs/development/compilers/llvm/9/default.nix @@ -63,21 +63,21 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libllvm-polly = callPackage ./llvm { inherit llvm_meta; enablePolly = true; }; - llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; }; + llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; }; libclang = callPackage ./clang { inherit clang-tools-extra_src llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; clang-polly-unwrapped = callPackage ./clang { inherit llvm_meta; diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 300de57b696e..fb2baf0e29a3 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -68,14 +68,14 @@ let }; # `llvm` historically had the binaries. When choosing an output explicitly, - # we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get* - llvm = tools.libllvm.out // { outputUnspecified = true; }; + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; libclang = callPackage ./clang { inherit llvm_meta; }; - clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; llvm-manpages = lowPrio (tools.libllvm.override { enableManpages = true;