aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2024-06-23 09:28:57 +0100
committerChristopher Baines <mail@cbaines.net>2024-06-25 13:19:12 +0100
commit84cafd6f4333c8bc8f43634cd34050e07b6f882f (patch)
treedad44b7d4de24bff063d4a49a8eaa7333dd05721
parent7f3e0949c43f464b7562c77364a14d7b5dfd0c4a (diff)
downloadbuild-coordinator-84cafd6f4333c8bc8f43634cd34050e07b6f882f.tar
build-coordinator-84cafd6f4333c8bc8f43634cd34050e07b6f882f.tar.gz
Add a utility thread pool
And use this to read derivations.
-rw-r--r--guix-build-coordinator/client-communication.scm15
-rw-r--r--guix-build-coordinator/coordinator.scm20
2 files changed, 29 insertions, 6 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm
index 3d780c4..354cb31 100644
--- a/guix-build-coordinator/client-communication.scm
+++ b/guix-build-coordinator/client-communication.scm
@@ -65,7 +65,8 @@
(define (start-client-request-server secret-key-base
host
port
- build-coordinator)
+ build-coordinator
+ utility-thread-pool-channel)
(run-server/patched
(lambda (request body)
(log-msg (build-coordinator-logger build-coordinator)
@@ -80,7 +81,8 @@
(uri-path (request-uri request))))
body
secret-key-base
- build-coordinator)))
+ build-coordinator
+ utility-thread-pool-channel)))
#:host host
#:port port))
@@ -88,7 +90,8 @@
method-and-path-components
raw-body
secret-key-base
- build-coordinator)
+ build-coordinator
+ utility-thread-pool-channel)
(define datastore
(build-coordinator-datastore build-coordinator))
@@ -483,7 +486,11 @@
(substitute-derivation store
derivation-file
#:substitute-urls substitute-urls)))
- (read-derivation-from-file* derivation-file))
+ ;; Read the derivation in a thread to avoid blocking fibers
+ (call-with-worker-thread
+ utility-thread-pool-channel
+ (lambda ()
+ (read-derivation-from-file* derivation-file))))
(let ((submit-build-result
(call-with-delay-logging
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm
index 2d7f3d9..59891d1 100644
--- a/guix-build-coordinator/coordinator.scm
+++ b/guix-build-coordinator/coordinator.scm
@@ -504,7 +504,22 @@
;; to run-fibers being called.
(let ((output-hash-channel
(make-output-hash-channel
- build-coordinator)))
+ build-coordinator))
+
+ (utility-thread-pool-channel
+ (make-worker-thread-channel
+ (const '())
+ #:name "utility"
+ #:parallelism 6
+ #:delay-logger
+ (lambda (seconds-delayed)
+ (log-delay "utility thread channel"
+ seconds-delayed)
+ (when (> seconds-delayed 0.1)
+ (format
+ (current-error-port)
+ "warning: utility thread channel delayed by ~1,2f seconds~%"
+ seconds-delayed))))))
(let ((finished? (make-condition)))
(call-with-sigint
@@ -575,7 +590,8 @@
secret-key-base
(uri-host client-communication-uri)
(uri-port client-communication-uri)
- build-coordinator)
+ build-coordinator
+ utility-thread-pool-channel)
;; Guile seems to just stop listening on ports, so try to
;; monitor that internally and just quit if it happens