From f58b45350b0ebfc36a707d9e986f5fe904af3605 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 27 Oct 2019 18:55:44 +0100 Subject: gexp: Add 'imported+compiled-modules'. * guix/gexp.scm (imported+compiled-modules): New procedure. (lower-gexp): Use it instead of separate calls to 'imported-modules' and 'compiled-modules'. --- guix/gexp.scm | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'guix/gexp.scm') diff --git a/guix/gexp.scm b/guix/gexp.scm index 7323277511..fa74e80cd6 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -654,6 +654,28 @@ (define-record-type (load-path lowered-gexp-load-path) ;list of store items (load-compiled-path lowered-gexp-load-compiled-path)) ;list of store items +(define* (imported+compiled-modules modules system + #:key (extensions '()) + deprecation-warnings guile + (module-path %load-path)) + "Return a pair where the first element is the imported MODULES and the +second element is the derivation to compile them." + (mlet %store-monad ((modules (if (pair? modules) + (imported-modules modules + #:system system + #:module-path module-path) + (return #f))) + (compiled (if (pair? modules) + (compiled-modules modules + #:system system + #:module-path module-path + #:extensions extensions + #:guile guile + #:deprecation-warnings + deprecation-warnings) + (return #f)))) + (return (cons modules compiled)))) + (define* (lower-gexp exp #:key (module-path %load-path) @@ -719,20 +741,15 @@ (define (search-path modules extensions suffix) (lambda (obj) (lower-object obj system)) extensions)) - (modules (if (pair? %modules) - (imported-modules %modules - #:system system - #:module-path module-path) - (return #f))) - (compiled (if (pair? %modules) - (compiled-modules %modules - #:system system - #:module-path module-path - #:extensions extensions - #:guile guile - #:deprecation-warnings - deprecation-warnings) - (return #f)))) + (modules+compiled (imported+compiled-modules + %modules system + #:extensions extensions + #:deprecation-warnings + deprecation-warnings + #:guile guile + #:module-path module-path)) + (modules -> (car modules+compiled)) + (compiled -> (cdr modules+compiled))) (define load-path (search-path modules exts (string-append "/share/guile/site/" effective-version))) -- cgit v1.2.3 From f5fca9a82cec76d2e10b8b6c96be2dd79f638ba0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 27 Oct 2019 19:12:11 +0100 Subject: gexp: Cache the module to derivation mappings. This reduces the number of 'add-data-to-store' cache lookups from 3329 to 2743 (hit rate: 27% to 11%) when running: GUIX_PROFILING=add-data-to-store-cache guix build libreoffice -nd Execution time of "guix build libreoffice -nd" goes from 1.86s to 1.80s. * guix/gexp.scm (imported+compiled-modules): Wrap body in 'mcached'. --- guix/gexp.scm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'guix/gexp.scm') diff --git a/guix/gexp.scm b/guix/gexp.scm index fa74e80cd6..b640c079e4 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -660,21 +660,24 @@ (define* (imported+compiled-modules modules system (module-path %load-path)) "Return a pair where the first element is the imported MODULES and the second element is the derivation to compile them." - (mlet %store-monad ((modules (if (pair? modules) - (imported-modules modules - #:system system - #:module-path module-path) - (return #f))) - (compiled (if (pair? modules) - (compiled-modules modules - #:system system - #:module-path module-path - #:extensions extensions - #:guile guile - #:deprecation-warnings - deprecation-warnings) - (return #f)))) - (return (cons modules compiled)))) + (mcached equal? + (mlet %store-monad ((modules (if (pair? modules) + (imported-modules modules + #:system system + #:module-path module-path) + (return #f))) + (compiled (if (pair? modules) + (compiled-modules modules + #:system system + #:module-path module-path + #:extensions extensions + #:guile guile + #:deprecation-warnings + deprecation-warnings) + (return #f)))) + (return (cons modules compiled))) + modules + system extensions guile deprecation-warnings module-path)) (define* (lower-gexp exp #:key -- cgit v1.2.3