GNU bug report logs -
#48007
computing derivations through inferior takes twice as long
Previous Next
Reported by: Ricardo Wurmus <rekado <at> elephly.net>
Date: Sat, 24 Apr 2021 21:08:02 UTC
Severity: important
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #10 received at 48007 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi!
Ricardo Wurmus <rekado <at> elephly.net> skribis:
> When INFERIOR is set to “y”, each package specification will be
> looked up in the current Guix via an inferior. For any other
> values of INFERIOR the specifications are resolved with the
> current Guix (the very same Guix) directly.
>
> Here are the timings:
>
> $ [env] export GUIX_PROFILING="object-cache
> add-data-to-store-cache rpc"
> $ [env] time INFERIOR=n guix build -m manifest-test.scm -d
> /gnu/store/mwg47gbmi98bbrywk07y5l2h9p6d1hz5-bash-minimal-5.0.16.drv
> /gnu/store/kcjk6z128fa07pzp8irp6lbbyl3g16nr-r-corrplot-0.84.drv
[...]
> $ [env] time INFERIOR=y guix build -m manifest-test.scm -d
With the manifest you gave in this message, I get roughly these
wall-clock times as of 3993d33d1c0129b1ca6f0fd122fe2bbe48e4f093 for:
guix build -m the-manifest.scm -n
INFERIOR=n 4.1s
INFERIOR=y 36.9s
With the patch below, it’s down to:
INFERIOR=y 9.3s
The trick is to ensure the inferior maintains its object cache across
calls. The patch needs to be cleaned up because it peeks into
internals, but we should be able to do something along these lines and
optimize a couple of other things.
If you can give it a spin on a more representative example, that’s
great!
Thanks,
Ludo’.
[Message part 2 (text/x-patch, inline)]
diff --git a/guix/inferior.scm b/guix/inferior.scm
index 572114f626..f6866d2083 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -188,6 +188,8 @@ (define* (port->inferior pipe #:optional (close close-port))
(inferior-eval '(use-modules (srfi srfi-34)) result)
(inferior-eval '(define %package-table (make-hash-table))
result)
+ (inferior-eval '(define %previous-object-cache #f)
+ result)
result))
(_
#f)))
@@ -559,6 +561,10 @@ (define (inferior-eval-with-store inferior store code)
(let ((store (if (defined? 'port->connection)
(port->connection socket #:version ,proto)
(open-connection))))
+ (when %previous-object-cache
+ (set-store-connection-cache! store (@@ (guix store) %object-cache-id)
+ %previous-object-cache))
+
(dynamic-wind
(const #t)
(lambda ()
@@ -570,6 +576,9 @@ (define (inferior-eval-with-store inferior store code)
`(store-protocol-error ,(error-message c))))
`(result ,(proc store))))
(lambda ()
+ (set! %previous-object-cache
+ (store-connection-cache store
+ (@@ (guix store) %object-cache-id)))
(close-connection store)
(close-port socket)))))
inferior)
This bug report was last modified 3 years and 88 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.