Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 13c128fb1c70
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3ace1b0d543e
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 24, 2020

  1. lib.lists.unique: Switch from recursive function to using a fold

    This improves performance by ~30-40% for smaller test cases and makes
    larger cases where my laptop would OOM pass in seconds.
    
    (cherry picked from commit 85605c8)
    adisbladis committed Nov 24, 2020
    Copy the full SHA
    be88ad4 View commit details
  2. texlive: Use lib.unique for uniqueness checks

    In 85605c8 we got a really nice
    performance improvement.
    
    By using this implementation for texlive instantiation RSS is cut by
    ~2.6x with a similar wall time speedup.
    
    (cherry picked from commit ce84cc0)
    adisbladis committed Nov 24, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3ace1b0 View commit details
Showing with 2 additions and 14 deletions.
  1. +1 −7 lib/lists.nix
  2. +1 −7 pkgs/tools/typesetting/tex/texlive/combine.nix
8 changes: 1 addition & 7 deletions lib/lists.nix
Original file line number Diff line number Diff line change
@@ -640,13 +640,7 @@ rec {
unique [ 3 2 3 4 ]
=> [ 3 2 4 ]
*/
unique = list:
if list == [] then
[]
else
let
x = head list;
in [x] ++ unique (remove x list);
unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];

/* Intersects list 'e' and another list. O(nm) complexity.
8 changes: 1 addition & 7 deletions pkgs/tools/typesetting/tex/texlive/combine.nix
Original file line number Diff line number Diff line change
@@ -31,13 +31,7 @@ let
++ lib.optional (lib.any pkgNeedsRuby splitBin.wrong) ruby;
};

# TODO: replace by buitin once it exists
fastUnique = comparator: list: with lib;
let un_adj = l: if length l < 2 then l
else optional (head l != elemAt l 1) (head l) ++ un_adj (tail l);
in un_adj (lib.sort comparator list);

uniqueStrings = fastUnique (a: b: a < b);
uniqueStrings = list: lib.sort (a: b: a < b) (lib.unique list);

mkUniqueOutPaths = pkgs: uniqueStrings
(map (p: p.outPath) (builtins.filter lib.isDerivation pkgs));