aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nar-herder/database.scm8
-rw-r--r--nar-herder/server.scm4
-rw-r--r--scripts/nar-herder.in14
3 files changed, 18 insertions, 8 deletions
diff --git a/nar-herder/database.scm b/nar-herder/database.scm
index 2db561a..4fa145f 100644
--- a/nar-herder/database.scm
+++ b/nar-herder/database.scm
@@ -259,7 +259,8 @@ CREATE TABLE scheduled_cached_narinfo_removal (
"CREATE INDEX IF NOT EXISTS narinfo_files_narinfo_id
ON narinfo_files (narinfo_id);"))
-(define (setup-database database-file metrics-registry)
+(define* (setup-database database-file metrics-registry
+ #:key (reader-threads 1))
(define mmap-size #f)
(let ((db (db-open database-file)))
@@ -302,10 +303,7 @@ CREATE TABLE scheduled_cached_narinfo_removal (
#:name "db r"
;; Use a minimum of 2 and a maximum of 8 threads
- #:parallelism
- (min (max (current-processor-count)
- 2)
- 64)
+ #:parallelism reader-threads
#:delay-logger (let ((delay-metric
(make-histogram-metric
metrics-registry
diff --git a/nar-herder/server.scm b/nar-herder/server.scm
index dd59216..2b941b9 100644
--- a/nar-herder/server.scm
+++ b/nar-herder/server.scm
@@ -631,7 +631,9 @@
(make-scheduler #:parallelism 1))
(let* ((database (setup-database (assq-ref opts 'database)
- metrics-registry))
+ metrics-registry
+ #:reader-threads
+ (assq-ref opts 'database-reader-threads)))
(canonical-storage (and=> (assq-ref opts 'storage)
canonicalize-path))
diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in
index 459526e..67515dc 100644
--- a/scripts/nar-herder.in
+++ b/scripts/nar-herder.in
@@ -312,10 +312,16 @@
(lambda (opt name arg result)
(alist-cons 'parallelism
(string->number arg)
- (alist-delete 'parallelism result))))))
+ (alist-delete 'parallelism result))))
+
+ (option '("database-reader-threads") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'database-reader-threads
+ (string->number arg)
+ (alist-delete 'database-reader-threads result))))))
(define %server-option-defaults
- '((port . 8080)
+ `((port . 8080)
(host . "0.0.0.0")
(storage-limit . "none")
@@ -325,6 +331,10 @@
(recent-changes-limit . 32768)
+ (database-reader-threads . ,(min (max (current-processor-count)
+ 2)
+ 64))
+
(parallelism . 1)))
(define %check-options