aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-01-19 13:15:21 +0000
committerChristopher Baines <mail@cbaines.net>2022-01-19 13:15:21 +0000
commit77fb9786226e7ba447438f7dc025f028450b8d24 (patch)
tree532bfe68126dca235668b7e29f897d2c3fa37257 /guix-build-coordinator
parente43c265870b8abb4d9c69463e0eb4563553e23b2 (diff)
downloadbuild-coordinator-77fb9786226e7ba447438f7dc025f028450b8d24.tar
build-coordinator-77fb9786226e7ba447438f7dc025f028450b8d24.tar.gz
Improve the speed of initialising metrics
Do the allocation metrics at the start of the relevant thread, and do the initialisation in parallel via fibers.
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r--guix-build-coordinator/coordinator.scm32
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm69
2 files changed, 56 insertions, 45 deletions
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm
index f66acc1..a31168c 100644
--- a/guix-build-coordinator/coordinator.scm
+++ b/guix-build-coordinator/coordinator.scm
@@ -178,14 +178,6 @@
(lambda (port)
(simple-format port "~A\n" (getpid)))))
- (log-msg (build-coordinator-logger build-coordinator)
- 'INFO
- "initialising metrics")
- (with-time-logging
- "datastore initialise metrics"
- (datastore-initialise-metrics! (build-coordinator-datastore
- build-coordinator)))
-
(set-build-coordinator-allocator-thread!
build-coordinator
(make-build-allocator-thread build-coordinator))
@@ -255,6 +247,14 @@
(lambda ()
(run-fibers
(lambda ()
+ (log-msg (build-coordinator-logger build-coordinator)
+ 'INFO
+ "initialising metrics")
+ (with-time-logging
+ "datastore initialise metrics"
+ (datastore-initialise-metrics! (build-coordinator-datastore
+ build-coordinator)))
+
(datastore-spawn-fibers
(build-coordinator-datastore build-coordinator))
@@ -573,6 +573,22 @@
exn)
(exit 1))
(lambda ()
+ (let ((build-allocation-plan-total
+ (make-gauge-metric
+ (build-coordinator-metrics-registry build-coordinator)
+ "build_allocation_plan_total"
+ #:labels '(agent_id))))
+ (with-time-logging
+ "allocator initialise metrics"
+ (for-each (match-lambda
+ ((agent-id . count)
+ (metric-set build-allocation-plan-total
+ count
+ #:label-values
+ `((agent_id . ,agent-id)))))
+ (datastore-count-build-allocation-plan-entries
+ (build-coordinator-datastore build-coordinator)))))
+
(allocate-builds-loop))))))
trigger-build-allocation)
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index 6b813a2..3c3caa3 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -284,43 +284,38 @@ PRAGMA optimize;")))))
(setup-failures-total
(make-gauge-metric registry
"setup_failures_total"
- #:labels '(agent_id reason)))
- (build-allocation-plan-total
- (make-gauge-metric registry
- "build_allocation_plan_total"
- #:labels '(agent_id))))
-
- (for-each (match-lambda
- ((system . count)
- (metric-set builds-total
- count
- #:label-values
- `((system . ,system)))))
- (datastore-count-builds datastore))
- (for-each (match-lambda
- (((agent-id result) . count)
- (metric-set build-results-total
- count
- #:label-values
- `((agent_id . ,agent-id)
- (result . ,result)))))
- (datastore-count-build-results datastore))
-
- (for-each (match-lambda
- (((agent-id reason) . count)
- (metric-set setup-failures-total
- count
- #:label-values
- `((agent_id . ,agent-id)
- (reason . ,reason)))))
- (datastore-count-setup-failures datastore))
- (for-each (match-lambda
- ((agent-id . count)
- (metric-set build-allocation-plan-total
- count
- #:label-values
- `((agent_id . ,agent-id)))))
- (datastore-count-build-allocation-plan-entries datastore)))
+ #:labels '(agent_id reason))))
+
+ (letpar& ((build-counts
+ (datastore-count-builds datastore))
+ (build-result-counts
+ (datastore-count-build-results datastore))
+ (setup-failure-counts
+ (datastore-count-setup-failures datastore)))
+
+ (for-each (match-lambda
+ ((system . count)
+ (metric-set builds-total
+ count
+ #:label-values
+ `((system . ,system)))))
+ build-counts)
+ (for-each (match-lambda
+ (((agent-id result) . count)
+ (metric-set build-results-total
+ count
+ #:label-values
+ `((agent_id . ,agent-id)
+ (result . ,result)))))
+ build-result-counts)
+ (for-each (match-lambda
+ (((agent-id reason) . count)
+ (metric-set setup-failures-total
+ count
+ #:label-values
+ `((agent_id . ,agent-id)
+ (reason . ,reason)))))
+ setup-failure-counts)))
#t)
(define-method (datastore-update-metrics!