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'.
This commit is contained in:
Ludovic Courtès 2019-10-27 19:12:11 +01:00
parent c57e417eff
commit f5fca9a82c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -660,21 +660,24 @@ (define* (imported+compiled-modules modules system
(module-path %load-path)) (module-path %load-path))
"Return a pair where the first element is the imported MODULES and the "Return a pair where the first element is the imported MODULES and the
second element is the derivation to compile them." second element is the derivation to compile them."
(mlet %store-monad ((modules (if (pair? modules) (mcached equal?
(imported-modules modules (mlet %store-monad ((modules (if (pair? modules)
#:system system (imported-modules modules
#:module-path module-path) #:system system
(return #f))) #:module-path module-path)
(compiled (if (pair? modules) (return #f)))
(compiled-modules modules (compiled (if (pair? modules)
#:system system (compiled-modules modules
#:module-path module-path #:system system
#:extensions extensions #:module-path module-path
#:guile guile #:extensions extensions
#:deprecation-warnings #:guile guile
deprecation-warnings) #:deprecation-warnings
(return #f)))) deprecation-warnings)
(return (cons modules compiled)))) (return #f))))
(return (cons modules compiled)))
modules
system extensions guile deprecation-warnings module-path))
(define* (lower-gexp exp (define* (lower-gexp exp
#:key #:key