aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-09-11 13:45:54 +0100
committerChristopher Baines <mail@cbaines.net>2023-09-12 13:11:00 +0100
commit97981d0c30116acf3fb5bc3e3cfa5cca90109911 (patch)
treed44e1b2874c171f8466280ab2be558142d500958
parent5997318263207a54c57f39357d0c261fd2d83c0f (diff)
downloadnar-herder-97981d0c30116acf3fb5bc3e3cfa5cca90109911.tar
nar-herder-97981d0c30116acf3fb5bc3e3cfa5cca90109911.tar.gz
Remove the get-nar-files call from the fetch changes fiber
As this is quite expensive.
-rw-r--r--nar-herder/mirror.scm32
1 files changed, 15 insertions, 17 deletions
diff --git a/nar-herder/mirror.scm b/nar-herder/mirror.scm
index 4ccf878..874a59b 100644
--- a/nar-herder/mirror.scm
+++ b/nar-herder/mirror.scm
@@ -40,13 +40,6 @@
(define (start-fetch-changes-fiber database storage-root
mirror metrics-registry)
- (define nar-files-metric
- (or (metrics-registry-fetch-metric metrics-registry
- "nar_files_total")
- (make-gauge-metric metrics-registry
- "nar_files_total"
- #:labels '(stored))))
-
(define (request-recent-changes)
(define latest-recent-change
(database-select-latest-recent-change-datetime database))
@@ -127,13 +120,21 @@
(assq-ref change-details
'datetime))
- (let ((new-files-count (length (narinfo-uris narinfo))))
- (metric-increment nar-files-metric
- #:by new-files-count
- ;; TODO This should be
- ;; checked, rather than
- ;; assumed to be false
- #:label-values '((stored . "false"))))))
+ (and=> (metrics-registry-fetch-metric metrics-registry
+ "nar_files_total")
+ (lambda (metric)
+ ;; Just update this metric if it
+ ;; exists, since if it does, it
+ ;; should be set to a value
+ (let ((new-files-count
+ (length (narinfo-uris narinfo))))
+ (metric-increment
+ metric
+ #:by new-files-count
+ ;; TODO This should be
+ ;; checked, rather than
+ ;; assumed to be false
+ #:label-values '((stored . "false"))))))))
((string=? change "removal")
(let ((store-path (assq-ref change-details 'data)))
(log-msg 'INFO "processing removal change for "
@@ -163,9 +164,6 @@
(spawn-fiber
(lambda ()
- ;; This will initialise the nar_files_total metric
- (get-nar-files database storage-root metrics-registry)
-
(while #t
(with-exception-handler
(lambda (exn)