From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:55852) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j5T8d-0004eL-B3 for guix-patches@gnu.org; Sat, 22 Feb 2020 06:40:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j5T8c-0007TF-0k for guix-patches@gnu.org; Sat, 22 Feb 2020 06:40:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42648) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j5T8b-0007TB-UG for guix-patches@gnu.org; Sat, 22 Feb 2020 06:40:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j5T8b-0004ob-Py for guix-patches@gnu.org; Sat, 22 Feb 2020 06:40:01 -0500 Subject: [bug#39734] [PATCH] scripts: Emit GC hint if free space is lower than absolute and relative threshold. Resent-Message-ID: From: Pierre Neidhardt In-Reply-To: <874kvizxi6.fsf@gnu.org> References: <20200222104653.1324-1-mail@ambrevar.xyz> <874kvizxi6.fsf@gnu.org> Date: Sat, 22 Feb 2020 12:39:19 +0100 Message-ID: <87tv3ig8bc.fsf@ambrevar.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" 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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 39734@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 warning= is >> + ;; emitted. >> + (make-parameter (match (and=3D> (getenv "GUIX_DISK_SPACE_WARNING_ABSO= LUTE") >> + string->number) >> + (#f 17.0) >> + (threshold threshold)))) > > Perhaps we should arrange for =E2=80=98GUIX_DISK_SPACE_WARNING=E2=80=99 t= o 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 frac= tion. I thought of something similar too, but this needs discussion: =2D If we change the meaning of a value like "1", we are breaking backward = compatibility. =2D 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 :) =2D 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. =2D 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. =2D Alternatively, since we are breaking backward compatibility anyways, we could parse a trailing percent sign "%" to decide whether the value is relative or absolute. 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? >> + (absolute-threshold-in-bytes (* 1024 1024 1024 absolute-thresh= old))) > > Always use bytes internally; that is, convert to bytes at the UI border. What do you mean? =2D-=20 Pierre Neidhardt https://ambrevar.xyz/ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEUPM+LlsMPZAEJKvom9z0l6S7zH8FAl5REucACgkQm9z0l6S7 zH8+UAf/XVDObcYFPWaGbkTYJ+0CLw4Jh6yUC3REG1pAphVz6zVRTC3EN24kA2Zz vVmLojFxklEaYaoK3WcHGROcxoM1MXKeXYWF/ZUF5ObbemRCrJrQzruMFdRYClfK XhFgGaR0sdEkR5od0u/j7XaipCm1qrSgcAKohsSngCxCIfamn3fr4eHJ1tVWmH0y X0RA2oPairrewN1sT/T/7QL0cjO5Mo9smrXSxRwM+HGWyysbSvQPdXKwDqbvHqlM Z/Ty2+XbqX9dmzch1bCn95pYM1W3lqs8Xkhiyg1D/SQd8p8qWpYw/ep4B0DZOgWp j/81PqkScdM7zl/A1q7s/DwOgadpSg== =Gfjh -----END PGP SIGNATURE----- --=-=-=--