emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#39734: closed ([PATCH] scripts: Emit GC hint if free space is lower


From: GNU bug Tracking System
Subject: bug#39734: closed ([PATCH] scripts: Emit GC hint if free space is lower than absolute and relative threshold.)
Date: Wed, 26 Feb 2020 21:07:02 +0000

Your message dated Wed, 26 Feb 2020 22:06:47 +0100
with message-id <address@hidden>
and subject line Re: [bug#39734] [PATCH] scripts: Emit GC hint if free space is 
lower than absolute and relative threshold.
has caused the debbugs.gnu.org bug report #39734,
regarding [PATCH] scripts: Emit GC hint if free space is lower than absolute 
and relative threshold.
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
39734: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=39734
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] scripts: Emit GC hint if free space is lower than absolute and relative threshold. Date: Sat, 22 Feb 2020 11:46:53 +0100
* guix/scripts.scm (%disk-space-warning-absolute): New variable.
(warn-about-disk-space): Test against %disk-space-warning-absolute.
Fix error in display-hint due to extraneous 'profile' argument.
---
 guix/scripts.scm | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/guix/scripts.scm b/guix/scripts.scm
index 77cbf12350..f8cce3a542 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -188,25 +188,35 @@ Show what and how will/would be built."
                     (#f        .05)               ;5%
                     (threshold (/ threshold 100.)))))
 
+(define %disk-space-warning-absolute
+  ;; The decimal number of GiB of free disk space below which a warning is
+  ;; emitted.
+  (make-parameter (match (and=> (getenv "GUIX_DISK_SPACE_WARNING_ABSOLUTE")
+                                string->number)
+                    (#f        17.0)
+                    (threshold threshold))))
+
 (define* (warn-about-disk-space #:optional profile
                                 #:key
-                                (threshold (%disk-space-warning)))
+                                (relative-threshold (%disk-space-warning))
+                                (absolute-threshold 
(%disk-space-warning-absolute)))
   "Display a hint about 'guix gc' if less than THRESHOLD of /gnu/store is
 available."
   (let* ((stats      (statfs (%store-prefix)))
          (block-size (file-system-block-size stats))
          (available  (* block-size (file-system-blocks-available stats)))
          (total      (* block-size (file-system-block-count stats)))
-         (ratio      (/ available total 1.)))
-    (when (< ratio threshold)
-      (warning (G_ "only ~,1f% of free space available on ~a~%")
-               (* ratio 100) (%store-prefix))
+         (relative-threshold-in-bytes (* total relative-threshold))
+         (absolute-threshold-in-bytes (* 1024 1024 1024 absolute-threshold)))
+    (when (< available (min relative-threshold-in-bytes
+                            absolute-threshold-in-bytes))
+      (warning (G_ "only ~,1f GiB of free space available on ~a~%")
+               available (%store-prefix))
       (display-hint (format #f (G_ "Consider deleting old profile
 generations and collecting garbage, along these lines:
 
 @example
 guix gc --delete-generations=1m
-@end example\n")
-                            profile)))))
+@end example\n"))))))
 
 ;;; scripts.scm ends here
-- 
2.25.0




--- End Message ---
--- Begin Message --- Subject: Re: [bug#39734] [PATCH] scripts: Emit GC hint if free space is lower than absolute and relative threshold. Date: Wed, 26 Feb 2020 22:06:47 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Hello,

Pierre Neidhardt <address@hidden> skribis:

> Ludovic Courtès <address@hidden> writes:
>
>>> +  (let* ((default-absolute-threshold (size->number "5GiB"))
>>> +         (default-relative-threshold 0.05)
>>> +         (percentage->float (lambda (percentage)
>>> +                              (or (and=> (string->number
>>> +                                          (car (string-split percentage 
>>> #\%)))
>>
>> Mayes just: (string-drop-right percentage 1).
>
> This does not work if the value does not have a percent sign, e.g. it
> turns "13" into "1".
>
> Resubmitting the patch with the other change.
> Feel free to merge! ;)

Perfect, I pushed it on your behalf.

Thank you for your patience!

Ludo’.


--- End Message ---

reply via email to

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