diff options
author | Christopher Baines <mail@cbaines.net> | 2024-11-08 12:59:08 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-11-08 12:59:08 +0000 |
commit | 0c1e9ad4e466be19f992571ac4fecbbbe2237edf (patch) | |
tree | 5d8805a360508c6246307c8017197a9d6dc87c88 | |
parent | 7ffe82dfe3a94e98c7e46ded20502bfe1cc91105 (diff) | |
download | data-service-0c1e9ad4e466be19f992571ac4fecbbbe2237edf.tar data-service-0c1e9ad4e466be19f992571ac4fecbbbe2237edf.tar.gz |
Do more when cleaning inferiors
Not sure if this actually helps, but it might do.
-rw-r--r-- | guix-data-service/jobs/load-new-guix-revision.scm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 2511783..5f9e5b3 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -1926,6 +1926,20 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1" (define chunk-size 1000) (define (inferior-cleanup inferior) + (inferior-eval + '(let ((stats (gc-stats))) + (simple-format + (current-error-port) + "cleaning up inferior (heap: ~a MiB used (~a MiB heap))~%" + (round + (/ (- (assoc-ref stats 'heap-size) + (assoc-ref stats 'heap-free-size)) + (expt 2. 20))) + (round + (/ (assoc-ref stats 'heap-size) + (expt 2. 20))))) + inferior) + (catch 'match-error (lambda () @@ -1936,12 +1950,40 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1" (current-error-port) "warning: ignoring match-error from calling inferior invalidate-derivation-caches!\n"))) + ;; Generating derivations populates the derivation cache + (inferior-eval + '(hash-clear! (@@ (guix derivations) %derivation-cache)) + inferior) + ;; 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) + + (inferior-eval + '(hash-for-each + (lambda (key _) + ((@ (guix memoization) invalidate-memoization!) key)) + (@@ (guix memoization) %memoization-tables)) + inferior) + + (inferior-eval '(gc) inferior) + + (inferior-eval + '(let ((stats (gc-stats))) + (simple-format + (current-error-port) + "finished cleaning up inferior (heap: ~a MiB used (~a MiB heap))~%" + (round + (/ (- (assoc-ref stats 'heap-size) + (assoc-ref stats 'heap-free-size)) + (expt 2. 20))) + (round + (/ (assoc-ref stats 'heap-size) + (expt 2. 20))))) inferior)) (define (get-derivations system target) |