Merge pull request #194391 from guibou/fast_haskell_ghc_with_packages

This commit is contained in:
Bernardo Meurer 2022-10-07 14:31:25 -03:00 committed by GitHub
commit 34c73b3fb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 2 deletions

View file

@ -157,7 +157,36 @@ rec {
}
);
closePropagation = list: (uniqList {inputList = (innerClosePropagation [] list);});
closePropagationSlow = list: (uniqList {inputList = (innerClosePropagation [] list);});
# This is an optimisation of lib.closePropagation which avoids the O(n^2) behavior
# Using a list of derivations, it generates the full closure of the propagatedXXXBuildInputs
# The ordering / sorting / comparison is done based on the `outPath`
# attribute of each derivation.
# On some benchmarks, it performs up to 15 times faster than lib.closePropagation.
# See https://github.com/NixOS/nixpkgs/pull/194391 for details.
closePropagationFast = list:
builtins.map (x: x.val) (builtins.genericClosure {
startSet = builtins.map (x: {
key = x.outPath;
val = x;
}) (builtins.filter (x: x != null) list);
operator = item:
if !builtins.isAttrs item.val then
[ ]
else
builtins.concatMap (x:
if x != null then [{
key = x.outPath;
val = x;
}] else
[ ]) ((item.val.propagatedBuildInputs or [ ])
++ (item.val.propagatedNativeBuildInputs or [ ]));
});
closePropagation = if builtins ? genericClosure
then closePropagationFast
else closePropagationSlow;
# calls a function (f attr value ) for each record item. returns a list
mapAttrsFlatten = f: r: map (attr: f attr r.${attr}) (attrNames r);

View file

@ -130,6 +130,15 @@
certificates by default.
</para>
</listitem>
<listitem>
<para>
Improved performances of
<literal>lib.closePropagation</literal> which was previously
quadratic. This is used in e.g.
<literal>ghcWithPackages</literal>. Please see backward
incompatibilities notes below.
</para>
</listitem>
<listitem>
<para>
Cinnamon has been updated to 5.4. While at it, the cinnamon
@ -556,6 +565,12 @@
notes</link>.
</para>
</listitem>
<listitem>
<para>
<literal>lib.closePropagation</literal> now needs that all
gathered sets have an <literal>outPath</literal> attribute.
</para>
</listitem>
<listitem>
<para>
lemmy module option

View file

@ -52,6 +52,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- Perl has been updated to 5.36, and its core module `HTTP::Tiny` was patched to verify SSL/TLS certificates by default.
- Improved performances of `lib.closePropagation` which was previously quadratic. This is used in e.g. `ghcWithPackages`. Please see backward incompatibilities notes below.
- Cinnamon has been updated to 5.4. While at it, the cinnamon module now defaults to
blueman as bluetooth manager and slick-greeter as lightdm greeter to match upstream.
@ -184,6 +186,8 @@ Available as [services.patroni](options.html#opt-services.patroni.enable).
- `teleport` has been upgraded to major version 10. Please see upstream [upgrade instructions](https://goteleport.com/docs/ver/10.0/management/operations/upgrading/) and [release notes](https://goteleport.com/docs/ver/10.0/changelog/#1000).
- `lib.closePropagation` now needs that all gathered sets have an `outPath` attribute.
- lemmy module option `services.lemmy.settings.database.createLocally`
moved to `services.lemmy.database.createLocally`.

View file

@ -36,7 +36,6 @@ let
This index includes documentation for many Haskell modules.
'';
# TODO: closePropagation is deprecated; replace
docPackages = lib.closePropagation
# we grab the doc outputs
(map (lib.getOutput "doc") packages);