store: 'map/accumulate-builds' preserves caches.

Fixes <https://issues.guix.gnu.org/55721>.

Starting from the switch to functional object caches ca.
9e5812ac59, we would be losing accumulated
caches when aborting to the build handler.  This patch fixes that.

In particular, by preserving '%reference-cache-id', we avoid redundant
'query-references' RPCs, which accounted for a large part of the extra
processing time.

* guix/store.scm (build-accumulator): When returning an <unresolved>
node, call 'set-store-connection-caches!' before and after to preserve
caches.
(map/accumulate-builds): Pass STORE as the first argument to
the <unresolved> continuation.
This commit is contained in:
Ludovic Courtès 2022-05-30 15:58:05 +02:00
parent 281bf72745
commit 1ae0e1dc29
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 13 additions and 2 deletions

View File

@ -1337,7 +1337,17 @@ object, only for build requests on EXPECTED-STORE."
(if (and (eq? (store-connection-socket store)
(store-connection-socket expected-store))
(= mode (build-mode normal)))
(unresolved things continue)
(begin
;; Preserve caches accumulated up to this handler invocation.
(set-store-connection-caches! expected-store
(store-connection-caches store))
(unresolved things
(lambda (new-store value)
;; Borrow caches from NEW-STORE.
(set-store-connection-caches!
store (store-connection-caches new-store))
(continue value))))
(continue #t))))
(define default-cutoff
@ -1397,7 +1407,8 @@ CUTOFF is the threshold above which we stop accumulating unresolved nodes."
(if (unresolved? obj)
;; Pass #f because 'build-things' is now
;; unnecessary.
((unresolved-continuation obj) #f)
((unresolved-continuation obj)
store #f)
obj))
result #:cutoff cutoff)
(map/accumulate-builds store proc rest #:cutoff cutoff)))))