From: "Ludovic Courtès" <ludo@gnu.org>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: 39734@debbugs.gnu.org
Subject: [bug#39734] [PATCH] scripts: Emit GC hint if free space is lower than absolute and relative threshold.
Date: Sun, 23 Feb 2020 12:46:38 +0100 [thread overview]
Message-ID: <87h7zhttk1.fsf@gnu.org> (raw)
In-Reply-To: <87tv3ig8bc.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Sat, 22 Feb 2020 12:39:19 +0100")
Hello!
Pierre Neidhardt <mail@ambrevar.xyz> skribis:
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hi!
>>
>> Pierre Neidhardt <mail@ambrevar.xyz> skribis:
>>
>>> * 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.
>>
>> [...]
>>
>>> +(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))))
>>
>> Perhaps we should arrange for ‘GUIX_DISK_SPACE_WARNING’ to handle both
>> cases?
>>
>> That is, we’d first try to convert it with ‘size->number’; if that
>> works, it’s an absolute measure, and if it returns #f, then pass the
>> string to ‘string->number’ and assume it’s a fraction.
>
> I thought of something similar too, but this needs discussion:
>
> - If we change the meaning of a value like "1", we are breaking backward compatibility.
We can assume values <= 100 are a percentage.
> - GUIX_DISK_SPACE_WARNING is currently undocumented, so I guess it's OK
> to break backward compatibility. However, it'd be nice to document it :)
Yup.
> - Currently (size->number "1.MiB") "leaves" the Guile instance on error. Which
> I find quite weird, I'd expect it to return #f when it cannot parse
> the input.
Fixed.
> - Currently (size->number "0.8") returns 1. If we want to use your
> suggestion, we would need to change the behaviour so that it returns
> #f.
Hmm.
> - Alternatively, since we are breaking backward compatibility anyways,
> we could parse a trailing percent sign "%" to decide whether the value
> is relative or absolute.
Right.
> Anyways, the issue was originally about dealing with both small and big
> partitions, and for this we need both a default absolute threshold and a
> default relative threshold. Does that make sense?
It does!
So how about this:
We check for a trailing “%”, and if there’s one, assume it’s a percentage.
Else, call ‘size->number’. If we get an integer < 100, assume it’s a
percentage, otherwise assume it’s an absolute size in bytes.
How does that sound?
Thanks!
Ludo’.
next prev parent reply other threads:[~2020-02-23 11:48 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-22 10:46 [bug#39734] [PATCH] scripts: Emit GC hint if free space is lower than absolute and relative threshold Pierre Neidhardt
2020-02-22 11:12 ` Ludovic Courtès
2020-02-22 11:39 ` Pierre Neidhardt
2020-02-23 11:46 ` Ludovic Courtès [this message]
2020-02-23 11:49 ` Pierre Neidhardt
2020-02-23 14:34 ` Ludovic Courtès
2020-02-23 14:41 ` Pierre Neidhardt
2020-02-23 16:09 ` Ludovic Courtès
2020-02-23 16:36 ` Pierre Neidhardt
2020-02-23 21:05 ` Pierre Neidhardt
2020-02-23 21:11 ` Pierre Neidhardt
2020-02-24 10:21 ` Ludovic Courtès
2020-02-24 10:26 ` Pierre Neidhardt
2020-02-24 13:20 ` Pierre Neidhardt
2020-02-24 21:08 ` Ludovic Courtès
2020-02-25 10:22 ` Pierre Neidhardt
2020-02-25 10:23 ` Pierre Neidhardt
2020-02-27 23:19 ` Ludovic Courtès
2020-02-28 7:17 ` Pierre Neidhardt
2020-03-05 16:29 ` Ludovic Courtès
2020-03-06 7:32 ` Pierre Neidhardt
2020-02-26 21:06 ` bug#39734: " Ludovic Courtès
2020-02-24 13:20 ` [bug#39734] " Pierre Neidhardt
2020-02-23 21:40 ` Ludovic Courtès
2020-02-24 7:51 ` Pierre Neidhardt
2020-02-24 7:52 ` Pierre Neidhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h7zhttk1.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=39734@debbugs.gnu.org \
--cc=mail@ambrevar.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.