From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:60682) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j5pjv-0003WB-CW for guix-patches@gnu.org; Sun, 23 Feb 2020 06:48:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j5pju-0005mS-9M for guix-patches@gnu.org; Sun, 23 Feb 2020 06:48:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j5pju-0005mI-5z for guix-patches@gnu.org; Sun, 23 Feb 2020 06:48:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j5pju-0004s8-3h for guix-patches@gnu.org; Sun, 23 Feb 2020 06:48:02 -0500 Subject: [bug#39734] [PATCH] scripts: Emit GC hint if free space is lower than absolute and relative threshold. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20200222104653.1324-1-mail@ambrevar.xyz> <874kvizxi6.fsf@gnu.org> <87tv3ig8bc.fsf@ambrevar.xyz> Date: Sun, 23 Feb 2020 12:46:38 +0100 In-Reply-To: <87tv3ig8bc.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Sat, 22 Feb 2020 12:39:19 +0100") Message-ID: <87h7zhttk1.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Pierre Neidhardt Cc: 39734@debbugs.gnu.org Hello! Pierre Neidhardt skribis: > Ludovic Court=C3=A8s writes: > >> Hi! >> >> Pierre Neidhardt 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 warnin= g is >>> + ;; emitted. >>> + (make-parameter (match (and=3D> (getenv "GUIX_DISK_SPACE_WARNING_ABS= OLUTE") >>> + string->number) >>> + (#f 17.0) >>> + (threshold threshold)))) >> >> Perhaps we should arrange for =E2=80=98GUIX_DISK_SPACE_WARNING=E2=80=99 = to handle both >> cases? >> >> That is, we=E2=80=99d first try to convert it with =E2=80=98size->number= =E2=80=99; if that >> works, it=E2=80=99s an absolute measure, and if it returns #f, then pass= the >> string to =E2=80=98string->number=E2=80=99 and assume it=E2=80=99s a fra= ction. > > 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 <=3D 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 =E2=80=9C%=E2=80=9D, and if there=E2=80=99s one, = assume it=E2=80=99s a percentage. Else, call =E2=80=98size->number=E2=80=99. If we get an integer < 100, a= ssume it=E2=80=99s a percentage, otherwise assume it=E2=80=99s an absolute size in bytes. How does that sound? Thanks! Ludo=E2=80=99.