[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/09: Support getting resource pool stats
From: |
Christopher Baines |
Subject: |
02/09: Support getting resource pool stats |
Date: |
Wed, 19 Jul 2023 08:37:12 -0400 (EDT) |
cbaines pushed a commit to branch master
in repository data-service.
commit 899bd1387e5517393b86718783ba0fc786fce531
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sun Jul 9 18:06:00 2023 +0100
Support getting resource pool stats
---
guix-data-service/utils.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/guix-data-service/utils.scm b/guix-data-service/utils.scm
index ec974e3..7212e9b 100644
--- a/guix-data-service/utils.scm
+++ b/guix-data-service/utils.scm
@@ -35,6 +35,7 @@
make-resource-pool
call-with-resource-from-pool
with-resource-from-pool
+ resource-pool-stats
parallel-via-fibers
par-map&
@@ -158,6 +159,23 @@
(cons resource available)
;; clear waiters, as they've been notified
'()))
+ (('stats reply)
+ (let ((stats
+ `((resources . ,(length resources))
+ (available . ,(length available))
+ (waiters . ,(length waiters)))))
+
+ (perform-operation
+ (choice-operation
+ (wrap-operation
+ (put-operation reply stats)
+ (const #t))
+ (wrap-operation (sleep-operation 0.2)
+ (const #f)))))
+
+ (loop resources
+ available
+ waiters))
(unknown
(simple-format
(current-error-port)
@@ -255,6 +273,11 @@ available. Return the resource once PROC has returned."
pool
(lambda (resource) exp ...)))
+(define (resource-pool-stats pool)
+ (let ((reply (make-channel)))
+ (put-message pool `(stats ,reply))
+ (get-message reply)))
+
(define (defer-to-parallel-fiber thunk)
(let ((reply (make-channel)))
(spawn-fiber
- branch master updated (672ee62 -> de6d380), Christopher Baines, 2023/07/19
- 06/09: Drop the resource pool timeout, Christopher Baines, 2023/07/19
- 02/09: Support getting resource pool stats,
Christopher Baines <=
- 03/09: Expose resource pool stats, Christopher Baines, 2023/07/19
- 05/09: Reduce the number of threads used by fibers, Christopher Baines, 2023/07/19
- 07/09: Make fetching metrics work even when having database problems, Christopher Baines, 2023/07/19
- 01/09: Stop using a pool of threads for database operations, Christopher Baines, 2023/07/19
- 04/09: Set thread names, Christopher Baines, 2023/07/19
- 08/09: Tweak loading package derivations, Christopher Baines, 2023/07/19
- 09/09: Tweak which duplicate packages to select, Christopher Baines, 2023/07/19