summaryrefslogtreecommitdiff
path: root/guix/derivations.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-10-27 15:24:41 +0100
committerLudovic Courtès <ludo@gnu.org>2019-10-27 23:04:59 +0100
commitf726f6f8021e78b6a50ca0dbdb4acc91ed2161c4 (patch)
tree3d48fe188a1a81503c38350466d302c1915bcb47 /guix/derivations.scm
parentcf7648f882380dd7a4e82760ecc10cc6078498eb (diff)
derivations: 'build-expression->derivation' caches its module derivations.
This reduces the number of lookups in the 'add-data-to-store' cache from 7505 to 3329 (hit rate from 68% to 27%) when running: GUIX_PROFILING=add-data-to-store-cache guix build libreoffice -nd The execution time of "guix build libreoffice -nd" goes from 2.12s to 1.87s. * guix/derivations.scm (%module-cache): New variable. (imported+compiled-modules)[key]: New variable. Lookup KEY in %MODULE-CACHE and populate %MODULE-CACHE upon cache miss.
Diffstat (limited to 'guix/derivations.scm')
-rw-r--r--guix/derivations.scm16
1 files changed, 14 insertions, 2 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm
index 8309f845d9..140c22b620 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -1207,13 +1207,25 @@ they can refer to each other."
#:guile-for-build guile
#:local-build? #t)))
+(define %module-cache
+ ;; Map a list of modules to its 'imported+compiled-modules' result.
+ (make-weak-value-hash-table))
+
(define* (imported+compiled-modules store modules #:key
(system (%current-system))
(guile (%guile-for-build)))
"Return a pair containing the derivation to import MODULES and that where
MODULES are compiled."
- (cons (%imported-modules store modules #:system system #:guile guile)
- (%compiled-modules store modules #:system system #:guile guile)))
+ (define key
+ (list modules (derivation-file-name guile) system))
+
+ (or (hash-ref %module-cache key)
+ (let ((result (cons (%imported-modules store modules
+ #:system system #:guile guile)
+ (%compiled-modules store modules
+ #:system system #:guile guile))))
+ (hash-set! %module-cache key result)
+ result)))
(define* (build-expression->derivation store name exp ;deprecated
#:key