aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/utils.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix-build-coordinator/utils.scm')
-rw-r--r--guix-build-coordinator/utils.scm36
1 files changed, 36 insertions, 0 deletions
diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm
index e633c05..5370d10 100644
--- a/guix-build-coordinator/utils.scm
+++ b/guix-build-coordinator/utils.scm
@@ -93,6 +93,7 @@
running-on-the-hurd?
get-gc-metrics-updater
+ get-guix-memory-metrics-updater
check-locale!))
@@ -1224,6 +1225,41 @@ again."
(metric-set metric value))))
metrics))))
+(define (get-guix-memory-metrics-updater registry)
+ (define %memoization-tables
+ (@@ (guix memoization) %memoization-tables))
+
+ (define memoization-table-entry-count-metric
+ (make-gauge-metric
+ registry "guix_memoization_table_entry_count"
+ #:labels '(procedure)))
+
+ (define %derivation-cache
+ (@@ (guix derivations) %derivation-cache))
+
+ (define derivation-cache-entry-count-metric
+ (make-gauge-metric
+ registry "guix_derivation_cache_entry_count"))
+
+ (lambda ()
+ (metric-set
+ derivation-cache-entry-count-metric
+ ;; hash-count doesn't work for weak tables?
+ (hash-fold (lambda (k v result)
+ (+ 1 result))
+ 0
+ %derivation-cache))
+
+ (hash-for-each
+ (lambda (proc table)
+ (metric-set
+ memoization-table-entry-count-metric
+ (hash-count (const #t) table)
+ #:label-values `((procedure . ,(simple-format
+ #f "~A"
+ proc)))))
+ %memoization-tables)))
+
(define (check-locale!)
(with-exception-handler
(lambda (exn)