[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Expose Guile GC metrics
From: |
Christopher Baines |
Subject: |
branch master updated: Expose Guile GC metrics |
Date: |
Sun, 09 Oct 2022 06:14:34 -0400 |
This is an automated email from the git hooks/post-receive script.
cbaines pushed a commit to branch master
in repository data-service.
The following commit(s) were added to refs/heads/master by this push:
new 8dd1646 Expose Guile GC metrics
8dd1646 is described below
commit 8dd164665a41b7fc4265bad8b43f28b936741bae
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sun Oct 9 11:13:28 2022 +0100
Expose Guile GC metrics
As the guix-data-service process seems to be using excessive amounts of
memory, and this will be useful to track it.
---
guix-data-service/utils.scm | 32 +++++++++++++++++++++++++++++++-
guix-data-service/web/controller.scm | 8 +++++++-
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/guix-data-service/utils.scm b/guix-data-service/utils.scm
index 6be5cc5..20ac3c0 100644
--- a/guix-data-service/utils.scm
+++ b/guix-data-service/utils.scm
@@ -24,6 +24,7 @@
#:use-module (fibers)
#:use-module (fibers channels)
#:use-module (fibers conditions)
+ #:use-module (prometheus)
#:export (call-with-time-logging
with-time-logging
prevent-inlining-for-tests
@@ -37,7 +38,9 @@
chunk!
chunk-for-each!
- delete-duplicates/sort!))
+ delete-duplicates/sort!
+
+ get-gc-metrics-updater))
(define (call-with-time-logging action thunk)
(simple-format #t "debug: Starting ~A\n" action)
@@ -243,3 +246,30 @@
current-element
(cons current-element
result)))))))))
+
+(define (get-gc-metrics-updater registry)
+ (define metrics
+ `((gc-time-taken
+ . ,(make-gauge-metric registry "guile_gc_time_taken"))
+ (heap-size
+ . ,(make-gauge-metric registry "guile_heap_size"))
+ (heap-free-size
+ . ,(make-gauge-metric registry "guile_heap_free_size"))
+ (heap-total-allocated
+ . ,(make-gauge-metric registry "guile_heap_total_allocated"))
+ (heap-allocated-since-gc
+ . ,(make-gauge-metric registry "guile_allocated_since_gc"))
+ (protected-objects
+ . ,(make-gauge-metric registry "guile_gc_protected_objects"))
+ (gc-times
+ . ,(make-gauge-metric registry "guile_gc_times"))))
+
+ (lambda ()
+ (let ((stats (gc-stats)))
+ (for-each
+ (match-lambda
+ ((name . metric)
+ (let ((value (assq-ref stats name)))
+ (metric-set metric value))))
+ metrics))))
+
diff --git a/guix-data-service/web/controller.scm
b/guix-data-service/web/controller.scm
index a29382a..7aac071 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -149,7 +149,11 @@
"-"
"_"))
#:labels '(name))))
- pg-stat-indexes-fields)))
+ pg-stat-indexes-fields))
+
+ (gc-metrics-updater
+ (get-gc-metrics-updater registry)))
+
(lambda ()
(letpar& ((metric-values
(with-thread-postgresql-connection
@@ -234,6 +238,8 @@
(state . ,state)))))
load-new-guix-revision-job-metrics)
+ (gc-metrics-updater)
+
(list (build-response
#:code 200
#:headers '((content-type . (text/plain))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Expose Guile GC metrics,
Christopher Baines <=