database: Enable running up to 4 database queries at once.

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.
This commit is contained in:
Christopher Baines 2020-01-24 19:22:22 +00:00
parent faf4bfdfcb
commit b9031db946
1 changed files with 3 additions and 1 deletions

View File

@ -439,7 +439,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)))