[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/11: derivations: 'build-expression->derivation' caches its module der
From: |
guix-commits |
Subject: |
02/11: derivations: 'build-expression->derivation' caches its module derivations. |
Date: |
Sun, 27 Oct 2019 18:13:07 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit f726f6f8021e78b6a50ca0dbdb4acc91ed2161c4
Author: Ludovic Courtès <address@hidden>
Date: Sun Oct 27 15:24:41 2019 +0100
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.
---
guix/derivations.scm | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/guix/derivations.scm b/guix/derivations.scm
index 8309f84..140c22b 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
- branch master updated (6d18427 -> b13b938), guix-commits, 2019/10/27
- 02/11: derivations: 'build-expression->derivation' caches its module derivations.,
guix-commits <=
- 01/11: derivations: Introduce 'imported+compiled-modules'., guix-commits, 2019/10/27
- 04/11: store: Allow objects in the cache to be inserted and search for with 'equal?'., guix-commits, 2019/10/27
- 03/11: gexp: Add 'imported+compiled-modules'., guix-commits, 2019/10/27
- 10/11: pull: Honor '/etc/guix/channels.scm'., guix-commits, 2019/10/27
- 08/11: gnu: bootstrap: Cache the 'bootstrap-executable' origins., guix-commits, 2019/10/27
- 06/11: derivations: Don't memoize 'derivation->bytevector'., guix-commits, 2019/10/27
- 05/11: gexp: Cache the module to derivation mappings., guix-commits, 2019/10/27
- 11/11: news: Add entry for /etc/guix/channels.scm., guix-commits, 2019/10/27
- 07/11: gnu: bootstrap: 'bootstrap-origin' preserves eq?-ness when no changes are made., guix-commits, 2019/10/27
- 09/11: channels: Refer to 'guile-json-3'., guix-commits, 2019/10/27