aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-09-23 21:02:13 +0100
committerChristopher Baines <mail@cbaines.net>2020-09-23 21:02:13 +0100
commitede295385fca2c54637600c4137ee1d74abd8532 (patch)
tree173a41361ad0d750728f606b9e3c3c0e12c7c47b
parentb8437b3034803767ecc2195e7bdfc3154b090621 (diff)
downloadbuild-coordinator-ede295385fca2c54637600c4137ee1d74abd8532.tar
build-coordinator-ede295385fca2c54637600c4137ee1d74abd8532.tar.gz
Track the number of builds the allocator is considering
-rw-r--r--guix-build-coordinator/build-allocator.scm31
-rw-r--r--guix-build-coordinator/coordinator.scm4
2 files changed, 32 insertions, 3 deletions
diff --git a/guix-build-coordinator/build-allocator.scm b/guix-build-coordinator/build-allocator.scm
index 94cfd03..0e65c4d 100644
--- a/guix-build-coordinator/build-allocator.scm
+++ b/guix-build-coordinator/build-allocator.scm
@@ -22,6 +22,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (ice-9 match)
+ #:use-module (prometheus)
#:use-module (guix memoization)
#:use-module (guix-build-coordinator utils)
#:use-module (guix-build-coordinator datastore)
@@ -31,7 +32,8 @@
(define* (basic-build-allocation-strategy datastore
#:key
- (planned-builds-for-agent-limit 2048))
+ (planned-builds-for-agent-limit 2048)
+ metrics-registry)
(define (log . args)
(when #f
(simple-format #t "allocator: ~A\n"
@@ -40,6 +42,14 @@
args)
" "))))
+ (define allocator-considered-builds-metric
+ (when metrics-registry
+ (let ((name "allocator_considered_builds"))
+ (or (metrics-registry-fetch-metric metrics-registry
+ name)
+ (make-gauge-metric metrics-registry
+ name)))))
+
(define cached/list-builds-for-output
(mlambda (output)
(datastore-list-builds-for-output datastore output)))
@@ -197,6 +207,10 @@
required-build-id
priority))))
+ (when metrics-registry
+ (metric-set allocator-considered-builds-metric
+ (length builds)))
+
;; Go through the setup failures and look specifically at the
;; missing_inputs ones. Eliminate any missing_inputs failures if all the
;; missing inputs appear to have been built successfully, and update the
@@ -288,7 +302,8 @@
(define* (derivation-ordered-build-allocation-strategy
datastore
#:key
- (planned-builds-for-agent-limit 2048))
+ (planned-builds-for-agent-limit 2048)
+ metrics-registry)
(define (log . args)
(when #f
(simple-format #t "allocator: ~A\n"
@@ -297,6 +312,14 @@
args)
" "))))
+ (define allocator-considered-builds-metric
+ (when metrics-registry
+ (let ((name "allocator_considered_builds"))
+ (or (metrics-registry-fetch-metric metrics-registry
+ name)
+ (make-gauge-metric metrics-registry
+ name)))))
+
(let* ((agents (datastore-list-agents datastore))
(requested-systems-by-agent
(map (lambda (agent-details)
@@ -378,6 +401,10 @@
(b-priority (hash-ref derived-build-priorities-hash b)))
(< b-priority a-priority))))
+ (when metrics-registry
+ (metric-set allocator-considered-builds-metric
+ (length build-ids-for-unprocessed-builds-with-built-inputs)))
+
(let ((result
(append-map
(lambda (agent-id)
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm
index 97c439c..3a3d76f 100644
--- a/guix-build-coordinator/coordinator.scm
+++ b/guix-build-coordinator/coordinator.scm
@@ -268,7 +268,9 @@
(build-coordinator-allocation-strategy build-coordinator))
(new-plan
(with-time-logging "allocating builds"
- (allocator-proc datastore))))
+ (allocator-proc datastore
+ #:metrics-registry (build-coordinator-metrics-registry
+ build-coordinator)))))
(datastore-replace-build-allocation-plan datastore new-plan))
#t)