~ruther/guix-local

bd2318ef0dc73f76cce942741255f5b566dd5f28 — Rutherther 5 months ago 133910f
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 <ludo@gnu.org>
1 files changed, 19 insertions(+), 16 deletions(-)

M guix/inferior.scm
M guix/inferior.scm => guix/inferior.scm +19 -16
@@ 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