Use knots

A library of extracted Guile Fibers patterns and utilities.
This commit is contained in:
Christopher Baines 2024-12-15 19:08:28 +00:00
parent a33e32275e
commit 8b49884816
13 changed files with 154 additions and 1205 deletions

View file

@ -38,6 +38,12 @@
#:use-module (fibers timers)
#:use-module (fibers channels)
#:use-module (fibers operations)
#:use-module (knots)
#:use-module (knots queue)
#:use-module (knots promise)
#:use-module (knots parallelism)
#:use-module (knots resource-pool)
#:use-module (knots worker-threads)
#:use-module (guix monads)
#:use-module (guix base32)
#:use-module (guix store)
@ -1127,7 +1133,7 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
(insert-derivations)))
(unless (null? derivations)
(parallel-via-fibers
(fibers-parallel
(insert-sources derivations
derivation-ids)
(with-time-logging
@ -1906,7 +1912,7 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
(inferior-lint-checkers inferior)))))
(when inferior-lint-checkers-data
(letpar& ((lint-checker-ids
(fibers-let ((lint-checker-ids
(with-resource-from-pool postgresql-connection-pool conn
(lint-checkers->lint-checker-ids
conn
@ -2181,7 +2187,7 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
(with-time-logging
(simple-format #f "extract-information-from: ~A\n" store-item)
(parallel-via-fibers
(fibers-parallel
(begin
(fibers-force package-ids-promise)
#f)
@ -2267,7 +2273,7 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
extra-inferior-environment-variables)
(define utility-thread-channel
;; There might be high demand for this, so order the requests
(make-queueing-channel
(spawn-queueing-fiber
(call-with-default-io-waiters
(lambda ()
(make-worker-thread-channel
@ -2791,6 +2797,12 @@ SKIP LOCKED")
(exec-query conn "BEGIN")
;; (spawn-fiber
;; (lambda ()
;; (while #t
;; (sleep (* 60 5))
;; (profile-heap))))
(spawn-fiber
(lambda ()
(while (perform-operation
@ -2864,7 +2876,7 @@ SKIP LOCKED")
id))))))
(when result
(parallel-via-fibers
(fibers-parallel
(with-postgresql-connection
(simple-format #f "post load-new-guix-revision ~A counts" id)
(lambda (conn)