guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Mathieu Othacehe
Date: Wed, 14 Oct 2020 08:23:22 -0400 (EDT)

branch: master
commit 514f20a9b53ea575078ab9a413d38646bb48aa0b
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Thu Oct 8 19:41:09 2020 +0200

    Update metrics in a single transaction.
    
    * src/cuirass/metrics.scm (db-update-metrics): Update all metrics in a 
single
    transaction.
---
 src/cuirass/metrics.scm | 78 +++++++++++++++++++++++++------------------------
 1 file changed, 40 insertions(+), 38 deletions(-)

diff --git a/src/cuirass/metrics.scm b/src/cuirass/metrics.scm
index fa42e43..f244c01 100644
--- a/src/cuirass/metrics.scm
+++ b/src/cuirass/metrics.scm
@@ -328,41 +328,43 @@ timestamp) VALUES ("
 
 (define (db-update-metrics)
   "Compute and update all available metrics in database."
-  (define specifications
-    (map (cut assq-ref <> #:name) (db-get-specifications)))
-
-  ;; We can not update all evaluations metrics for performance reasons. Limit
-  ;; to the evaluations that were added during the past three days.
-  (define evaluations
-    (db-latest-evaluations))
-
-  (db-update-metric 'builds-per-day)
-  (db-update-metric 'new-derivations-per-day)
-  (db-update-metric 'pending-builds)
-
-  ;; Update specification related metrics.
-  (for-each (lambda (spec)
-              (db-update-metric
-               'average-10-last-eval-duration-per-spec spec)
-              (db-update-metric
-               'average-100-last-eval-duration-per-spec spec)
-              (db-update-metric
-               'average-eval-duration-per-spec spec)
-
-              (db-update-metric
-               'percentage-failure-10-last-eval-per-spec spec)
-              (db-update-metric
-               'percentage-failure-100-last-eval-per-spec spec)
-              (db-update-metric
-               'percentage-failed-eval-per-spec spec))
-            specifications)
-
-  ;; Update evaluation related metrics.
-  (for-each (lambda (evaluation)
-              (db-update-metric
-               'average-eval-build-start-time evaluation)
-              (db-update-metric
-               'average-eval-build-complete-time evaluation)
-              (db-update-metric
-               'evaluation-completion-speed evaluation))
-            evaluations))
+  (with-db-worker-thread db
+    ;; We can not update all evaluations metrics for performance reasons.
+    ;; Limit to the evaluations that were added during the past three days.
+    (let ((specifications
+           (map (cut assq-ref <> #:name) (db-get-specifications)))
+          (evaluations (db-latest-evaluations)))
+      (sqlite-exec db "BEGIN TRANSACTION;")
+
+      (db-update-metric 'builds-per-day)
+      (db-update-metric 'new-derivations-per-day)
+      (db-update-metric 'pending-builds)
+
+      ;; Update specification related metrics.
+      (for-each (lambda (spec)
+                  (db-update-metric
+                   'average-10-last-eval-duration-per-spec spec)
+                  (db-update-metric
+                   'average-100-last-eval-duration-per-spec spec)
+                  (db-update-metric
+                   'average-eval-duration-per-spec spec)
+
+                  (db-update-metric
+                   'percentage-failure-10-last-eval-per-spec spec)
+                  (db-update-metric
+                   'percentage-failure-100-last-eval-per-spec spec)
+                  (db-update-metric
+                   'percentage-failed-eval-per-spec spec))
+                specifications)
+
+      ;; Update evaluation related metrics.
+      (for-each (lambda (evaluation)
+                  (db-update-metric
+                   'average-eval-build-start-time evaluation)
+                  (db-update-metric
+                   'average-eval-build-complete-time evaluation)
+                  (db-update-metric
+                   'evaluation-completion-speed evaluation))
+                evaluations)
+
+      (sqlite-exec db "COMMIT;"))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]