Move the inferior cleanup to the end of each system+target

This commit is contained in:
Christopher Baines 2024-11-03 21:24:30 +00:00
parent cee8868bfd
commit d310632f26

View file

@ -620,19 +620,6 @@
'(define unsupported-cross-compilation-target-error? (const #f)) '(define unsupported-cross-compilation-target-error? (const #f))
inf)) inf))
(catch
'match-error
(lambda ()
(inferior-eval '(invalidate-derivation-caches!) inf))
(lambda (key . args)
(simple-format
(current-error-port)
"warning: ignoring match-error from calling inferior invalidate-derivation-caches!\n")))
;; Clean the cached store connections, as there are caches associated
;; with these that take up lots of memory
(inferior-eval '(when (defined? '%store-table) (hash-clear! %store-table)) inf)
(inferior-eval-with-store/non-blocking (inferior-eval-with-store/non-blocking
inf inf
store store
@ -1939,6 +1926,25 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
(define chunk-size 1000) (define chunk-size 1000)
(define (inferior-cleanup inferior)
(catch
'match-error
(lambda ()
(inferior-eval '(invalidate-derivation-caches!)
inferior))
(lambda (key . args)
(simple-format
(current-error-port)
"warning: ignoring match-error from calling inferior invalidate-derivation-caches!\n")))
;; Clean the cached store connections, as there are
;; caches associated with these that take up lots of
;; memory
(inferior-eval
'(when (defined? '%store-table)
(hash-clear! %store-table))
inferior))
(define (get-derivations system target) (define (get-derivations system target)
(let ((derivations-vector (make-vector packages-count))) (let ((derivations-vector (make-vector packages-count)))
(with-time-logging (with-time-logging
@ -1955,13 +1961,19 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
(lambda (inferior inferior-store) (lambda (inferior inferior-store)
(ensure-gds-inferior-packages-defined! inferior) (ensure-gds-inferior-packages-defined! inferior)
(let ((result
(inferior-package-derivations (inferior-package-derivations
inferior-store inferior-store
inferior inferior
system system
target target
start-index start-index
count))))) count)))
(when last-chunk?
(inferior-cleanup inferior))
result)))))
(vector-copy! derivations-vector (vector-copy! derivations-vector
start-index start-index
chunk) chunk)