diff mbox series

[bug#48826] scripts: substitute: Cache connection when looking for narinfos.

Message ID 20210604070223.10680-1-othacehe@gnu.org
State Accepted
Headers show
Series [bug#48826] scripts: substitute: Cache connection when looking for narinfos. | expand

Commit Message

Mathieu Othacehe June 4, 2021, 7:02 a.m. UTC
The process-substitution procedure is opening two distinct connections. The
first one when looking for narinfo by calling lookup-narinfo and the other one
when fetching nar files.

Cache the connection when looking for narinfos so that process-substitution
only opens one connection.

* guix/scripts/substitute.scm (lookup-narinfo): Cache connection by using
open-connection-for-uri/cached.
---
 guix/scripts/substitute.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ludovic Courtès June 5, 2021, 8:21 p.m. UTC | #1
Hi Mathieu,

Mathieu Othacehe <othacehe@gnu.org> skribis:

> The process-substitution procedure is opening two distinct connections. The
> first one when looking for narinfo by calling lookup-narinfo and the other one
> when fetching nar files.
>
> Cache the connection when looking for narinfos so that process-substitution
> only opens one connection.
>
> * guix/scripts/substitute.scm (lookup-narinfo): Cache connection by using
> open-connection-for-uri/cached.

Good catch, LGTM!

Thanks,
Ludo’.
Mathieu Othacehe June 6, 2021, 4:56 p.m. UTC | #2
Hey,

> Good catch, LGTM!

Pushed as a068ed6a5f5b3535fce49ac4eca1fec82edd6fdc.

Thanks,

Mathieu
diff mbox series

Patch

diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index 54311c3e08..44448ff3e9 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -163,7 +163,9 @@  if file doesn't exist, and the narinfo otherwise."
 (define (lookup-narinfo caches path authorized?)
   "Return the narinfo for PATH in CACHES, or #f when no substitute for PATH
 was found."
-  (match (lookup-narinfos/diverse caches (list path) authorized?)
+  (match (lookup-narinfos/diverse
+          caches (list path) authorized?
+          #:open-connection open-connection-for-uri/cached)
     ((answer) answer)
     (_        #f)))