[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/10: profiling: Add a "gc" profiling component.
From: |
guix-commits |
Subject: |
02/10: profiling: Add a "gc" profiling component. |
Date: |
Tue, 15 Jan 2019 14:24:38 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 461d6c2effb8520ecb088854efd517e2efd28d30
Author: Ludovic Courtès <address@hidden>
Date: Fri Jan 11 14:56:40 2019 +0100
profiling: Add a "gc" profiling component.
* guix/profiling.scm (show-gc-stats): New procedure.
<top level>: Call 'register-profiling-hook!'.
---
guix/profiling.scm | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/guix/profiling.scm b/guix/profiling.scm
index 753fc6c..e1c205a 100644
--- a/guix/profiling.scm
+++ b/guix/profiling.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2017 Ludovic Courtès <address@hidden>
+;;; Copyright © 2017, 2019 Ludovic Courtès <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -18,6 +18,7 @@
(define-module (guix profiling)
#:use-module (ice-9 match)
+ #:autoload (ice-9 format) (format)
#:export (profiled?
register-profiling-hook!))
@@ -50,3 +51,25 @@
(for-each (lambda (hook)
(add-hook! hook thunk))
%profiling-hooks)))
+
+(define (show-gc-stats)
+ "Display garbage collection statistics."
+ (define MiB (* 1024 1024.))
+ (define stats (gc-stats))
+
+ (format (current-error-port) "Garbage collection statistics:
+ heap size: ~,2f MiB
+ allocated: ~,2f MiB
+ GC times: ~a
+ time spent in GC: ~,2f seconds (~d% of user time)~%"
+ (/ (assq-ref stats 'heap-size) MiB)
+ (/ (assq-ref stats 'heap-total-allocated) MiB)
+ (assq-ref stats 'gc-times)
+ (/ (assq-ref stats 'gc-time-taken)
+ internal-time-units-per-second 1.)
+ (inexact->exact
+ (round (* (/ (assq-ref stats 'gc-time-taken)
+ (tms:utime (times)) 1.)
+ 100)))))
+
+(register-profiling-hook! "gc" show-gc-stats)
- branch master updated (b96909c -> b9da4b9), guix-commits, 2019/01/15
- 06/10: discovery: Add 'fold-module-public-variables*'., guix-commits, 2019/01/15
- 10/10: status: Distinguish 'package-cache' profile hook., guix-commits, 2019/01/15
- 05/10: inferior: Add 'gexp->derivation-in-inferior'., guix-commits, 2019/01/15
- 07/10: channels: Compute a package cache and use it., guix-commits, 2019/01/15
- 08/10: edit: Use 'specification->location' to read information from the cache., guix-commits, 2019/01/15
- 03/10: guix package: Avoid 'find-newest-available-packages'., guix-commits, 2019/01/15
- 01/10: gnu: Add gauche., guix-commits, 2019/01/15
- 09/10: guix package: '--list-available' can use data from the cache., guix-commits, 2019/01/15
- 02/10: profiling: Add a "gc" profiling component.,
guix-commits <=
- 04/10: packages: Remove 'find-newest-available-packages'., guix-commits, 2019/01/15