guix: Avoid ‘fdatasync’ call for caches and regular files.

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 <mail@cbaines.net>
Change-Id: I82297eae737bc5aae8a3f7604119e9f3d4b625bf
This commit is contained in:
Ludovic Courtès 2025-04-08 18:51:11 +02:00
parent 3271843122
commit dfac0a5a95
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
5 changed files with 13 additions and 8 deletions

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020, 2021, 2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019-2022, 2025 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@ -344,7 +344,8 @@ authenticated (only COMMIT-ID is written to cache, though)."
(chmod port #o600)
(display ";; List of previously-authenticated commits.\n\n"
port)
(pretty-print lst port))))))
(pretty-print lst port)))
#:sync? #f)))
;;;

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012-2018, 2020-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2012-2018, 2020-2022, 2025 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2012, 2015 Free Software Foundation, Inc.
;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
@ -346,7 +346,8 @@ Write information about redirects to LOG-PORT."
(when cache-port
(close-port cache-port))
(with-atomic-file-output file
(cut write-cache port <>))
(cut write-cache port <>)
#:sync? #f)
(close-port port)
(open-input-file file))))

View file

@ -87,7 +87,8 @@ lock on FILE to synchronize with any potential readers."
(format port "http://~a:~a~%"
(avahi-service-address service)
(avahi-service-port service)))
%publish-services)))
%publish-services))
#:sync? #f)
(chmod file #o644))
(define* (read-substitute-urls #:key (file (%publish-file)))

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021-2025 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
@ -554,7 +554,8 @@ are put in alphabetical order."
(apply pretty-print-with-comments/splice port lst
#:format-comment canonicalize-comment
#:format-vertical-space canonicalize-vertical-space
rest))))))
rest))
#:sync? #f))))
;;;

View file

@ -127,7 +127,8 @@ indicates that PATH is unavailable at CACHE-URL."
(mkdir-p (dirname file))
(with-atomic-file-output file
(lambda (out)
(write (cache-entry cache-url narinfo) out))))
(write (cache-entry cache-url narinfo) out))
#:sync? #f))
narinfo)