nix-gh/src
Eelco Dolstra 0395b9b94a
Add memoise primop
'builtins.memoise f x' is equal to 'f x', but uses a cache to speed up
repeated invocations of 'f' with the same 'x'. A typical application
is memoising evaluations of Nixpkgs in NixOps network
specifications. For example, with the patch below, the time to
evaluate a 10-machine NixOps network is reduced from 17.1s to 9.6s,
while memory consumption goes from 4486 MiB to 3089 MiB. (This is with
GC_INITIAL_HEAP_SIZE=16G.)

Nixpkgs patch:

diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix
index a9f21e45aed..f641067e022 100644
--- a/pkgs/top-level/impure.nix
+++ b/pkgs/top-level/impure.nix
@@ -79,7 +79,7 @@ in
 # not be passed.
 assert args ? localSystem -> !(args ? system || args ? platform);

-import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
+builtins.memoise or (x: x) (import ./.) (builtins.removeAttrs args [ "system" "platform" ] // {
   inherit config overlays crossSystem;
   # Fallback: Assume we are building packages on the current (build, in GNU
   # Autotools parlance) system.
2018-01-11 19:24:22 +01:00
..
boost Shut up some warnings 2017-04-14 14:42:20 +02:00
build-remote nix.conf: builders-use-substitutes 2018-01-09 22:40:07 +01:00
buildenv Fix "Unexpected EOF reading a line" error 2017-11-29 11:56:15 +00:00
libexpr Add memoise primop 2018-01-11 19:24:22 +01:00
libmain anchor nix::Exit exception 2017-11-14 12:39:30 -06:00
libstore nix.conf: builders-use-substitutes 2018-01-09 22:40:07 +01:00
libutil use libbrotli directly when available 2017-12-30 20:26:33 -06:00
linenoise linenoise.cpp: allow completions from empty input 2017-12-19 12:52:10 -06:00
nix nix repl: use linenoiseKeyType to differentiate ^C and ^D 2017-12-26 19:25:50 -06:00
nix-build nix-shell/nix-build: Support .drv files again 2017-11-24 18:08:35 +01:00
nix-channel Replace Unicode quotes in user-facing strings by ASCII 2017-07-30 12:32:45 +01:00
nix-collect-garbage printMsg(lvlError, ...) -> printError(...) etc. 2016-09-21 16:54:53 +02:00
nix-copy-closure Replace Unicode quotes in user-facing strings by ASCII 2017-07-30 12:32:45 +01:00
nix-daemon Improve error message with --repair for untrusted users 2018-01-08 19:13:48 +01:00
nix-env nix: Respect -I, --arg, --argstr 2017-10-24 12:58:34 +02:00
nix-instantiate nix: Respect -I, --arg, --argstr 2017-10-24 12:58:34 +02:00
nix-prefetch-url nix: Respect -I, --arg, --argstr 2017-10-24 12:58:34 +02:00
nix-store Pass lists/attrsets to bash as (associative) arrays 2017-10-25 13:01:50 +02:00
nlohmann Simplify build by including nlohmann/json.hpp 2017-12-04 17:11:36 +01:00
resolve-system-dependencies Replace Unicode quotes in user-facing strings by ASCII 2017-07-30 12:32:45 +01:00