guix_mirror_bot pushed a commit to branch master
in repository guix.

commit bd2318ef0dc73f76cce942741255f5b566dd5f28
Author: Rutherther <[email protected]>
AuthorDate: Tue Oct 14 17:02:31 2025 +0200

    inferior: cached-channel-instances: Optimize caching for (partially) locked 
channels.
    
    This makes it possible to skip the guix derivation calculation phase for
    channels.scm that aren't fully locked (specifically with missing channel
    dependencies).
    
    * guix/inferior.scm (cached-channel-instance): Return cached early after
    calculating latest-channel-instances.
    
    Change-Id: Ie77c1903c7a79b082e440046092fd697fd941afc
    Signed-off-by: Ludovic Courtès <[email protected]>
---
 guix/inferior.scm | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/guix/inferior.scm b/guix/inferior.scm
index f23d35c9ba..89f017c6e8 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -975,23 +975,26 @@ X.509 host certificate; otherwise, warn about the problem 
and keep going."
                                                            validate-channels
                                                            
#:verify-certificate?
                                                            
verify-certificate?))
-                             (commits -> (map channel-instance-commit 
instances))
-                             (profile
-                              (channel-instances->derivation instances)))
-          (mbegin %store-monad
-            ;; It's up to the caller to install a build handler to report
-            ;; what's going to be built.
-            (built-derivations (list profile))
-
-            ;; Cache if and only if AUTHENTICATE? is true.
-            (if authenticate?
+                             (commits -> (map channel-instance-commit 
instances)))
+          ;; Return early if cache is hit with filled channel dependencies.
+          (if (file-exists? (cached commits))
+              (return (cached commits))
+              (mlet* %store-monad ((profile
+                                     (channel-instances->derivation 
instances)))
                 (mbegin %store-monad
-                  (symlink* (derivation->output-path profile) (cached commits))
-                  (add-indirect-root* (cached commits))
-                  (return (cached commits)))
-                (mbegin %store-monad
-                  (add-temp-root* (derivation->output-path profile))
-                  (return (derivation->output-path profile)))))))))
+                  ;; It's up to the caller to install a build handler to report
+                  ;; what's going to be built.
+                  (built-derivations (list profile))
+
+                  ;; Cache if and only if AUTHENTICATE? is true.
+                  (if authenticate?
+                      (mbegin %store-monad
+                        (symlink* (derivation->output-path profile) (cached 
commits))
+                        (add-indirect-root* (cached commits))
+                        (return (cached commits)))
+                      (mbegin %store-monad
+                        (add-temp-root* (derivation->output-path profile))
+                        (return (derivation->output-path profile)))))))))))
 
 (define* (inferior-for-channels channels
                                 #:key

Reply via email to