From: Christopher Baines <mail@cbaines.net>
To: guix-devel@gnu.org
Subject: [PATCH 4/4] database: Enable running up to 4 database queries at once.
Date: Fri, 24 Jan 2020 19:44:06 +0000 [thread overview]
Message-ID: <20200124194406.29638-4-mail@cbaines.net> (raw)
In-Reply-To: <20200124194406.29638-1-mail@cbaines.net>
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
next prev parent reply other threads:[~2020-01-24 19:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-24 19:44 [PATCH 1/4] utils: Change critical section terminology to worker threads Christopher Baines
2020-01-24 19:44 ` [PATCH 2/4] Adjust make-worker-thread-channel to take an initializer Christopher Baines
2020-01-24 19:44 ` [PATCH 3/4] Enable make-worker-thread-channel to create multiple worker threads Christopher Baines
2020-01-24 19:44 ` Christopher Baines [this message]
2020-01-25 17:47 ` [PATCH 4/4] database: Enable running up to 4 database queries at once Ludovic Courtès
2020-01-25 17:46 ` [PATCH 1/4] utils: Change critical section terminology to worker threads Ludovic Courtès
2020-01-25 22:59 ` Christopher Baines
2020-01-28 10:27 ` Ludovic Courtès
2020-01-28 17:19 ` Christopher Baines
2020-01-29 16:26 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200124194406.29638-4-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.