summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-02-18 22:25:18 +0100
committerLudovic Courtès <ludo@gnu.org>2021-02-23 15:24:47 +0100
commit70b33d8898031d0f8623922762442f4abf6adcc4 (patch)
tree57dd02357d3751004f15c49b8f2b3af40bfe4c2a
parentdb45712a675ada5cadc56c758d92894059af91f9 (diff)
downloadguix-70b33d8898031d0f8623922762442f4abf6adcc4.tar.gz
store: Object cache profiling shows the number of entries.
* guix/store.scm (record-cache-lookup!): Add 'size' variable; keep it
up-to-date and display it.
-rw-r--r--guix/store.scm13
1 files changed, 9 insertions, 4 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 81bb9eb847..dccf8ba1d9 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -1835,18 +1835,21 @@ and RESULT is typically its derivation."
   (if (profiled? "object-cache")
       (let ((fresh    0)
             (lookups  0)
-            (hits     0))
+            (hits     0)
+            (size     0))
         (register-profiling-hook!
          "object-cache"
          (lambda ()
            (format (current-error-port) "Store object cache:
   fresh caches: ~5@a
   lookups:      ~5@a
-  hits:         ~5@a (~,1f%)~%"
+  hits:         ~5@a (~,1f%)
+  cache size:   ~5@a entries~%"
                    fresh lookups hits
                    (if (zero? lookups)
                        100.
-                       (* 100. (/ hits lookups))))))
+                       (* 100. (/ hits lookups)))
+                   size)))
 
         (lambda (hit? cache)
           (set! fresh
@@ -1854,7 +1857,9 @@ and RESULT is typically its derivation."
                 (+ 1 fresh)
                 fresh))
           (set! lookups (+ 1 lookups))
-          (set! hits (if hit? (+ hits 1) hits))))
+          (set! hits (if hit? (+ hits 1) hits))
+          (set! size (+ (if hit? 0 1)
+                        (vlist-length cache)))))
       (lambda (x y)
         #t)))