From 037eac0357baa448afe6aeeaf82d8f2e2665bbcb Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 14 Oct 2024 13:12:53 +0100 Subject: Try to prioritise some database operations At the moment, hooks can get stuck behind new builds being submitted due to the slow writes. Try to manage this by prioritising the write operations from the hooks. --- guix-build-coordinator/datastore/sqlite.scm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index ac04362..1effb39 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -109,6 +109,7 @@ worker-reader-thread-channel worker-reader-thread-proc-vector worker-writer-thread-channel + worker-priority-writer-thread-channel worker-writer-thread-proc-vector metrics-registry) @@ -199,6 +200,10 @@ (slot-set! datastore 'worker-writer-thread-channel channel) + ;; This is changed in datastore-spawn-fibers + (slot-set! datastore + 'worker-priority-writer-thread-channel + channel) (slot-set! datastore 'worker-writer-thread-proc-vector proc-vector)) @@ -343,11 +348,11 @@ PRAGMA optimize;") (datastore )) ;; Queue messages to the writer thread, so that they're handled in a first ;; come first served manor - (slot-set! - datastore - 'worker-writer-thread-channel - (make-queueing-channel - (slot-ref datastore 'worker-writer-thread-channel))) + (let ((high low (make-discrete-priority-queueing-channels + (slot-ref datastore 'worker-writer-thread-channel) + 2))) + (slot-set! datastore 'worker-priority-writer-thread-channel high) + (slot-set! datastore 'worker-writer-thread-channel low)) (spawn-fiber (lambda () @@ -3177,7 +3182,7 @@ WHERE id = :id" (datastore ) id) (call-with-worker-thread - (slot-ref datastore 'worker-writer-thread-channel) + (slot-ref datastore 'worker-priority-writer-thread-channel) (lambda (db) (let ((statement (sqlite-prepare -- cgit v1.2.3