From 922697c8b27570b6c76a472266507b73f6b79f7f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 9 Mar 2006 15:09:18 +0000 Subject: * Big speedup (factor > 2.5) in all nix-env operations that do actual instantiation, e.g. "nix-env -i" and "nix-env -qas" (but not "nix-env -qa"). It turns out that many redundant calls to addToStore(path) were made, which reads and hashes the entire path. For instance, the bash bootstrap binary in Nixpkgs would be read and hashed many times. As a result nix-env would spend around 92% of its time in the function sha256_block (according to callgrind). Some simple memoization fixes this. --- src/libexpr/eval.hh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 11185159c123..602f63fdedaf 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -11,6 +11,10 @@ typedef map DrvRoots; typedef map DrvHashes; +/* Cache for calls to addToStore(); maps source paths to the store + paths. */ +typedef map SrcToStore; + struct EvalState; /* Note: using a ATermVector is safe here, since when we call a primop @@ -24,6 +28,7 @@ struct EvalState ATermMap primOps; DrvRoots drvRoots; DrvHashes drvHashes; /* normalised derivation hashes */ + SrcToStore srcToStore; Expr blackHole; unsigned int nrEvaluated; -- cgit 1.4.1