diff options
author | Ludovic Courtès <ludo@gnu.org> | 2021-03-22 22:34:43 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-03-30 22:48:45 +0200 |
commit | 324a2355796cd175673f982e5ad48ab8d12e05ee (patch) | |
tree | 34bf7d2cb3d1e22c720e3aec29bdf2446b72ca53 /guix/gexp.scm | |
parent | a779363b6aa581e88eda21f9f35530962d54ac25 (diff) |
gexp: Do not add derivations to the object cache.
That was needlessly making the object cache grow.
* guix/gexp.scm (lower-object, lower+expand-object): Bypass the object
cache when OBJ is a derivation. This almost halves the number of
cache lookups and reduces the number of entries from 3.4K to 2.6K when
doing "guix build libreoffice -d --no-grafts".
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r-- | guix/gexp.scm | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm index ab83c1e621..142717ed34 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -258,14 +258,17 @@ OBJ must be an object that has an associated gexp compiler, such as a (#f (raise (condition (&gexp-input-error (input obj))))) (lower - ;; Cache in STORE the result of lowering OBJ. - (mcached (mlet %store-monad ((lowered (lower obj system target))) - (if (and (struct? lowered) - (not (derivation? lowered))) - (loop lowered) - (return lowered))) - obj - system target graft?)))))) + ;; Cache in STORE the result of lowering OBJ. If OBJ is a + ;; derivation, bypass the cache. + (if (derivation? obj) + (return obj) + (mcached (mlet %store-monad ((lowered (lower obj system target))) + (if (and (struct? lowered) + (not (derivation? lowered))) + (loop lowered) + (return lowered))) + obj + system target graft?))))))) (define* (lower+expand-object obj #:optional (system (%current-system)) @@ -280,9 +283,11 @@ expand to file names, but it's possible to expand to a plain data type." (raise (condition (&gexp-input-error (input obj))))) (lower (mlet* %store-monad ((graft? (grafting?)) - (lowered (mcached (lower obj system target) - obj - system target graft?))) + (lowered (if (derivation? obj) + (return obj) + (mcached (lower obj system target) + obj + system target graft?)))) ;; LOWER might return something that needs to be further ;; lowered. (if (struct? lowered) |