Process queued build events in parallel

This commit is contained in:
Christopher Baines 2025-07-01 13:07:44 +01:00
parent 61780fe7ea
commit f1e444babe

View file

@ -35,6 +35,7 @@
#:use-module (knots)
#:use-module (knots web-server)
#:use-module (knots thread-pool)
#:use-module (knots parallelism)
#:use-module (knots resource-pool)
#:use-module (prometheus)
#:use-module (guix-data-service utils)
@ -246,15 +247,17 @@ port. Also, the port used can be changed by passing the --port option.\n"
exn)
(raise-exception exn))
(lambda ()
(let ((build-ids
(call-with-resource-from-pool (background-connection-pool)
(lambda (conn)
(let ((build-ids
(select-background-processing-build-ids conn)))
(select-background-processing-build-ids conn)))))
(unless (null? build-ids)
(simple-format #t "processing ~A builds from the background queue\n"
(length build-ids)))
(for-each
(fibers-batch-for-each
(lambda (build-id)
(call-with-resource-from-pool (background-connection-pool)
(lambda (conn)
(let ((status (select-latest-build-status-by-build-id
conn
build-id)))
@ -275,8 +278,11 @@ port. Also, the port used can be changed by passing the --port option.\n"
(list build-id)))))
(delete-background-processing-entries-for-build-ids
conn
(list build-id)))
build-ids)))))))
(list build-id)))))
(assq-ref (resource-pool-stats (background-connection-pool)
#:timeout #f)
'resources)
build-ids)))))
#:unwind? #t))
#:parallel? #t)