Subject: Re: [PATCH 4/4] guix: Avoid ‘fdatasync’ call for caches and regular files.

From: Christopher Baines <[email-masked]>
Date: Thu, 10 Apr 2025 11:34:55 +0100

Ludovic Courtès <[email-masked]> writes:

> Fixes <https://issues.guix.gnu.org/77606>.
>
> Calling ‘fdatasync’ for each and every narinfo file created by ‘guix
> substitute’ proved to be too expensive on spinning HDDs and/or under
> load (from 0.1s to 1.3s for the ‘fdatasync’ call alone).
>
> * guix/git-authenticate.scm (cache-authenticated-commit): Pass #:sync? #f.
> * guix/http-client.scm (http-fetch/cached): Likewise.
> * guix/scripts/discover.scm (write-publish-file): Likewise.
> * guix/scripts/style.scm (format-whole-file): Likewise.
> * guix/substitutes.scm (cache-narinfo!): Likewise.
>
> Reported-by: Christopher Baines <[email-masked]>
> Change-Id: I82297eae737bc5aae8a3f7604119e9f3d4b625bf
> ---
>  guix/git-authenticate.scm | 5 +++--
>  guix/http-client.scm      | 5 +++--
>  guix/scripts/discover.scm | 3 ++-
>  guix/scripts/style.scm    | 5 +++--
>  guix/substitutes.scm      | 3 ++-
>  5 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/guix/git-authenticate.scm b/guix/git-authenticate.scm
> index 37c69d0880..3cd1175c32 100644
> --- a/guix/git-authenticate.scm
> +++ b/guix/git-authenticate.scm
> @@ -1,5 +1,5 @@
>  ;;; GNU Guix --- Functional package management for GNU
> -;;; Copyright © 2019, 2020, 2021, 2022 Ludovic Courtès <[email-masked]>
> +;;; Copyright © 2019-2022, 2025 Ludovic Courtès <[email-masked]>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -344,7 +344,8 @@ (define (cache-authenticated-commit key commit-id)
>            (chmod port #o600)
>            (display ";; List of previously-authenticated commits.\n\n"
>                     port)
> -          (pretty-print lst port))))))
> +          (pretty-print lst port)))
> +      #:sync? #f)))

This introduces (or maybe increases) the risk that this file will be
empty, does this happen often enough to justify the change?