diff options
author | Christopher Baines <mail@cbaines.net> | 2023-08-03 10:07:33 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-08-03 10:07:33 +0100 |
commit | 4808d8f4e1483072a033a714f4f9090ff75cd87c (patch) | |
tree | 8d796d2363c82feabcbe254775fa9e19609783cd /guix-build-coordinator/utils.scm | |
parent | 11be46e5acc3517fd37642cfa05e9a71e5ee2274 (diff) | |
download | build-coordinator-4808d8f4e1483072a033a714f4f9090ff75cd87c.tar build-coordinator-4808d8f4e1483072a033a714f4f9090ff75cd87c.tar.gz |
Keep less derivation files open when reading derivations
This probably isn't the main problem with having too many open files, but it
might help avoid bursts of open files.
Diffstat (limited to 'guix-build-coordinator/utils.scm')
-rw-r--r-- | guix-build-coordinator/utils.scm | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 06c22c6..197c002 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -66,6 +66,8 @@ find-missing-substitutes-for-output has-substiutes-no-cache? + read-derivation-from-file* + substitute-derivation read-derivation-through-substitutes @@ -461,6 +463,23 @@ (error (simple-format #f "could not substitute ~A\n" derivation-name))))))))) +(define read-derivation-from-file* + (let ((%derivation-cache + (@@ (guix derivations) %derivation-cache))) + (lambda (file) + (or (and file (hash-ref %derivation-cache file)) + (let ((drv + ;; read-derivation can call read-derivation-from-file, so to + ;; avoid having many open files when reading a derivation with + ;; inputs, read it in to a string first. + (call-with-input-string + (call-with-input-file file + get-string-all) + (lambda (port) + (read-derivation port read-derivation-from-file*))))) + (hash-set! %derivation-cache file drv) + drv))))) + (define %derivation-cache (make-doubly-weak-hash-table)) @@ -551,13 +570,13 @@ (error "could not fetch narinfo")))) (with-store store - (define (read-derivation-from-file* derivation-name) + (define (read-derivation-from-file/custom derivation-name) (or (hash-ref %derivation-cache derivation-name) ;; Try the local store (and (file-exists? derivation-name) (valid-path? store derivation-name) - (read-derivation-from-file derivation-name)) + (read-derivation-from-file* derivation-name)) ;; Otherwise try the network (let ((drv @@ -566,7 +585,7 @@ (lambda (port) (set-port-filename! port derivation-name) (read-derivation port - read-derivation-from-file*))))) + read-derivation-from-file/custom))))) (hash-set! %derivation-cache derivation-name @@ -574,7 +593,7 @@ drv))) - (read-derivation-from-file* derivation-name))) + (read-derivation-from-file/custom derivation-name))) (define* (narinfo-string store-path hash size references compressed-files |