[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/07: store: Add "add-data-to-store-cache" profiling component.
From: |
guix-commits |
Subject: |
03/07: store: Add "add-data-to-store-cache" profiling component. |
Date: |
Tue, 16 Apr 2019 11:33:15 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit d1f7748a2e41f2ca320eca56b366933b8aa1123c
Author: Ludovic Courtès <address@hidden>
Date: Tue Apr 16 11:46:17 2019 +0200
store: Add "add-data-to-store-cache" profiling component.
* guix/store.scm (add-data-to-store): Define 'lookup' and use it instead
of 'hash-ref'.
---
guix/store.scm | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/guix/store.scm b/guix/store.scm
index 9c195c3..1b485ab 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -996,14 +996,52 @@ string). Raise an error if no such path exists."
(operation (add-text-to-store (string name) (bytevector text)
(string-list references))
#f
- store-path)))
+ store-path))
+ (lookup (if (profiled? "add-data-to-store-cache")
+ (let ((lookups 0)
+ (hits 0)
+ (drv 0)
+ (scheme 0))
+ (define (show-stats)
+ (define (% n)
+ (if (zero? lookups)
+ 100.
+ (* 100. (/ n lookups))))
+
+ (format (current-error-port) "
+'add-data-to-store' cache:
+ lookups: address@hidden
+ hits: address@hidden (~,1f%)
+ .drv files: address@hidden (~,1f%)
+ Scheme files: address@hidden (~,1f%)~%"
+ lookups hits (% hits)
+ drv (% drv)
+ scheme (% scheme)))
+
+ (register-profiling-hook! "add-data-to-store-cache"
+ show-stats)
+ (lambda (cache args)
+ (let ((result (hash-ref cache args)))
+ (set! lookups (+ 1 lookups))
+ (when result
+ (set! hits (+ 1 hits)))
+ (match args
+ ((_ name _)
+ (cond ((string-suffix? ".drv" name)
+ (set! drv (+ drv 1)))
+ ((string-suffix? "-builder" name)
+ (set! scheme (+ scheme 1)))
+ ((string-suffix? ".scm" name)
+ (set! scheme (+ scheme 1))))))
+ result)))
+ hash-ref)))
(lambda* (server name bytes #:optional (references '()))
"Add BYTES under file NAME in the store, and return its store path.
REFERENCES is the list of store paths referred to by the resulting store
path."
(let* ((args `(,bytes ,name ,references))
(cache (store-connection-add-text-to-store-cache server)))
- (or (hash-ref cache args)
+ (or (lookup cache args)
(let ((path (add-text-to-store server name bytes references)))
(hash-set! cache args path)
path))))))
- branch master updated (b744862 -> b2c3640), guix-commits, 2019/04/16
- 02/07: derivations: Reduce 'valid-path?' RPCs in 'derivation-prerequisites-to-build'., guix-commits, 2019/04/16
- 03/07: store: Add "add-data-to-store-cache" profiling component.,
guix-commits <=
- 01/07: store: Memoize 'built-in-builders' call directly in <store-connection>., guix-commits, 2019/04/16
- 07/07: tests: Gracefully skip zlib test when zlib is missing., guix-commits, 2019/04/16
- 04/07: gnu: guile-charting: Install .go files in the right place., guix-commits, 2019/04/16
- 05/07: gnu: Add libomp., guix-commits, 2019/04/16
- 06/07: gnu: slurm: Configure with a "standard" syslogdir., guix-commits, 2019/04/16