all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 50384@debbugs.gnu.org
Subject: [bug#50384] [PATCH] Optimise search-patch (reducing I/O)
Date: Sat, 04 Sep 2021 23:47:39 +0200	[thread overview]
Message-ID: <877dfwypvo.fsf@gnu.org> (raw)
In-Reply-To: <8900fa8c8eef7f72fc97adc2408be26c88de7803.camel@telenet.be> (Maxime Devos's message of "Sat, 04 Sep 2021 23:17:10 +0200")

Hi!

Some initial comments…

Maxime Devos <maximedevos@telenet.be> skribis:

> +++ b/guix/gexp.scm
> @@ -531,13 +531,37 @@ appears."
>  (define-gexp-compiler (local-file-compiler (file <local-file>) system target)
>    ;; "Compile" FILE by adding it to the store.
>    (match file
> -    (($ <local-file> file (= force absolute) name sha256 recursive? select?)
> -     ;; Canonicalize FILE so that if it's a symlink, it is resolved.  Failing
> -     ;; to do that, when RECURSIVE? is #t, we could end up creating a dangling
> -     ;; symlink in the store, and when RECURSIVE? is #f 'add-to-store' would
> -     ;; just throw an error, both of which are inconvenient.
> -     (interned-file absolute name
> -                    #:recursive? recursive? #:select? select?))))
> +    ;; Delay computing the absolute file name until 'intern', as this
> +    ;; might be a relatively expensive computation (e.g. if search-patch
> +    ;; is used), especially on a spinning disk.
> +    (($ <local-file> file absolute-promise name sha256 recursive? select?)
> +     (let ()
> +       (define (intern)
> +         ;; Canonicalize FILE so that if it's a symlink, it is resolved.
> +         ;; Failing to do that, when RECURSIVE? is #t, we could end up creating
> +         ;; a dangling symlink in the store, and when RECURSIVE? is #f
> +         ;; 'add-to-store' would just throw an error, both of which are
> +         ;; inconvenient.
> +         (interned-file (force absolute-promise) name
> +                        #:recursive? recursive? #:select? select?))
> +       (if sha256
> +           (let ((path (fixed-output-path name sha256 #:recursive? recursive?)))
> +             ;; If the hash is known in advance and the store already has the
> +             ;; item, there is no need to intern the file.
> +             (if (file-exists? path)
> +                 (mbegin %store-monad
> +                   ;; Tell the GC that PATH will be used, such that it won't
> +                   ;; be deleted.
> +                   ((store-lift add-temp-root) path)
> +                   ;; The GC could have deleted the item before add-temp-root
> +                   ;; completed, so check again if PATH exists.
> +                   (if (file-exists? path)
> +                       (return path)
> +                       ;; If it has been removed, fall-back interning.
> +                       (intern)))
> +                 ;; If PATH does not yet exist, fall back to interning.
> +                 (intern)))
> +           (intern))))))

‘file-exists?’ won’t work when talking to a remote store (e.g.,
GUIX_DAEMON_SOCKET=ssh://…).

‘add-temp-root’ doesn’t throw if the given store item does not exist.
So it could be written like this:

  (if sha256
      (mbegin %store-monad
        (add-temp-root* item)
        (if (valid-path?* item)
            (return item)
            (intern)))
      (intern))

But then, we’d add one RPC for every ‘add-to-store’ RPC corresponding to
a patch (you can set “GUIX_PROFILING=rpc” to see the numbers), which is
not great.

Ludo’.




  reply	other threads:[~2021-09-04 22:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04 21:17 [bug#50384] [PATCH] Optimise search-patch (reducing I/O) Maxime Devos
2021-09-04 21:47 ` Ludovic Courtès [this message]
2021-09-04 22:04 ` Ludovic Courtès
2021-09-05 19:48   ` [bug#50384] [PATCH v2] " Maxime Devos
2021-09-05 22:40     ` Maxime Devos
2021-09-06  8:39     ` zimoun
2021-09-06 10:06       ` Maxime Devos
2021-09-09 14:51     ` [bug#50384] [PATCH] " Ludovic Courtès
2021-09-21 16:55       ` [bug#50384] [PATCH v4] " Ludovic Courtès
2021-09-23 17:26         ` Maxime Devos
2021-09-27 16:17           ` Ludovic Courtès
2021-10-04 16:46             ` [bug#50384] [PATCH] " zimoun
2021-10-08  7:41               ` Ludovic Courtès
2021-10-11  8:09                 ` [bug#39258] bug#50384: " zimoun
2021-09-09 20:25 ` [bug#50384] [PATCH v3] " Maxime Devos
2021-09-10  9:54   ` bug#50384: " Maxime Devos

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=877dfwypvo.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=50384@debbugs.gnu.org \
    --cc=maximedevos@telenet.be \
    /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.