guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] database: Enable running up to 4 database queries at once.


From: Christopher Baines
Subject: [PATCH 4/4] database: Enable running up to 4 database queries at once.
Date: Fri, 24 Jan 2020 19:44:06 +0000

The number of threads is copied from bin/cuirass.in. When you have at least
two processors, this will allow database queries to be executed in parallel.

With some crude testing using the Apache HTTP server benchmarking tool (ab
from the httpd package), the max request latency does seem to drop when
multiple threads are used, especially when the database queries are slow (I
tested by adding usleep to the worker thread code).

* src/cuirass/database.scm (with-database): Pass #:parallelism to
make-worker-thread-channel.
---
 src/cuirass/database.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 0f5e38f..1585df4 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -440,7 +440,9 @@ worker thread that allows database operations to run 
without intefering with
 fibers."
   (parameterize ((%db-channel (make-worker-thread-channel
                                (lambda ()
-                                 (list (db-open))))))
+                                 (list (db-open)))
+                               #:parallelism
+                               (min (current-processor-count) 4))))
     body ...))
 
 (define* (read-quoted-string #:optional (port (current-input-port)))
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]