all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#46776] [PATCH] inferior: Extend cached-channel-instance scope.
@ 2021-02-25 17:20 Mathieu Othacehe
  2021-03-01 14:47 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Othacehe @ 2021-02-25 17:20 UTC (permalink / raw)
  To: 46776; +Cc: Mathieu Othacehe

* guix/inferior.scm (cached-channel-instance): Turn channels argument into
channels-or-instances.  Adapt the rest of the procedure.
---
 guix/inferior.scm | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/guix/inferior.scm b/guix/inferior.scm
index 0990696e6c..06a187b879 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -709,20 +709,30 @@ prefix, resolve it; and if 'commit' is unset, fetch CHANNEL's branch tip."
           commit))))
 
 (define* (cached-channel-instance store
-                                  channels
+                                  channels-or-instances
                                   #:key
                                   (authenticate? #t)
                                   (cache-directory (%inferior-cache-directory))
                                   (ttl (* 3600 24 30)))
-  "Return a directory containing a guix filetree defined by CHANNELS, a list of channels.
-The directory is a subdirectory of CACHE-DIRECTORY, where entries can be reclaimed after TTL seconds.
-This procedure opens a new connection to the build daemon.  AUTHENTICATE?
-determines whether CHANNELS are authenticated."
+  "Return a directory containing a guix filetree defined by
+CHANNELS-OR-INSTANCES, a list of channels or channel instances.  The directory
+is a subdirectory of CACHE-DIRECTORY, where entries can be reclaimed after TTL
+seconds.  This procedure opens a new connection to the build daemon.
+AUTHENTICATE?  determines whether CHANNELS are authenticated."
+  ;; Determine if we are dealing with channels or channel instances.
+  (define channels?
+    (match (pk channels-or-instances)
+      (((? channel? c) rest ...)
+       #t)
+      (else #f)))
+
   (define commits
     ;; Since computing the instances of CHANNELS is I/O-intensive, use a
     ;; cheaper way to get the commit list of CHANNELS.  This limits overhead
     ;; to the minimum in case of a cache hit.
-    (map channel-full-commit channels))
+    (if channels?
+      (map channel-full-commit channels-or-instances)
+      (map channel-instance-commit channels-or-instances)))
 
   (define key
     (bytevector->base32-string
@@ -756,9 +766,12 @@ determines whether CHANNELS are authenticated."
       cached
       (run-with-store store
         (mlet* %store-monad ((instances
-                              -> (latest-channel-instances store channels
-                                                           #:authenticate?
-                                                           authenticate?))
+                              -> (if channels?
+                                     (latest-channel-instances
+                                      store channels-or-instances
+                                      #:authenticate?
+                                      authenticate?)
+                                     channels-or-instances))
                              (profile
                               (channel-instances->derivation instances)))
           (mbegin %store-monad
-- 
2.30.1





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#46776] [PATCH] inferior: Extend cached-channel-instance scope.
  2021-02-25 17:20 [bug#46776] [PATCH] inferior: Extend cached-channel-instance scope Mathieu Othacehe
@ 2021-03-01 14:47 ` Ludovic Courtès
  2021-03-26  9:54   ` bug#46776: " Mathieu Othacehe
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2021-03-01 14:47 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 46776

Hi,

Mathieu Othacehe <othacehe@gnu.org> skribis:

> * guix/inferior.scm (cached-channel-instance): Turn channels argument into
> channels-or-instances.  Adapt the rest of the procedure.

[...]

>  (define* (cached-channel-instance store
> -                                  channels
> +                                  channels-or-instances
>                                    #:key
>                                    (authenticate? #t)
>                                    (cache-directory (%inferior-cache-directory))
>                                    (ttl (* 3600 24 30)))
> -  "Return a directory containing a guix filetree defined by CHANNELS, a list of channels.
> -The directory is a subdirectory of CACHE-DIRECTORY, where entries can be reclaimed after TTL seconds.
> -This procedure opens a new connection to the build daemon.  AUTHENTICATE?
> -determines whether CHANNELS are authenticated."
> +  "Return a directory containing a guix filetree defined by
> +CHANNELS-OR-INSTANCES, a list of channels or channel instances.  The directory
> +is a subdirectory of CACHE-DIRECTORY, where entries can be reclaimed after TTL
> +seconds.  This procedure opens a new connection to the build daemon.
> +AUTHENTICATE?  determines whether CHANNELS are authenticated."
> +  ;; Determine if we are dealing with channels or channel instances.
> +  (define channels?
> +    (match (pk channels-or-instances)
> +      (((? channel? c) rest ...)
> +       #t)
> +      (else #f)))
> +
>    (define commits
>      ;; Since computing the instances of CHANNELS is I/O-intensive, use a
>      ;; cheaper way to get the commit list of CHANNELS.  This limits overhead
>      ;; to the minimum in case of a cache hit.
> -    (map channel-full-commit channels))
> +    (if channels?
> +      (map channel-full-commit channels-or-instances)
> +      (map channel-instance-commit channels-or-instances)))

This would only accept homogeneous lists, which is kinda weird.

Could we instead have a separate procedure taking channel instances, and
arrange to factorize common code in a third procedure?

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#46776: [PATCH] inferior: Extend cached-channel-instance scope.
  2021-03-01 14:47 ` Ludovic Courtès
@ 2021-03-26  9:54   ` Mathieu Othacehe
  0 siblings, 0 replies; 3+ messages in thread
From: Mathieu Othacehe @ 2021-03-26  9:54 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 46776-done


Hello,

> This would only accept homogeneous lists, which is kinda weird.
>
> Could we instead have a separate procedure taking channel instances, and
> arrange to factorize common code in a third procedure?

I managed to rewrite Cuirass evaluation without modifying the inferior
API. Closing this one.

Thanks for having a look,

Mathieu




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-26  9:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25 17:20 [bug#46776] [PATCH] inferior: Extend cached-channel-instance scope Mathieu Othacehe
2021-03-01 14:47 ` Ludovic Courtès
2021-03-26  9:54   ` bug#46776: " Mathieu Othacehe

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.