From bd2318ef0dc73f76cce942741255f5b566dd5f28 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 14 Oct 2025 17:02:31 +0200 Subject: [PATCH] inferior: cached-channel-instances: Optimize caching for (partially) locked channels. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- guix/inferior.scm | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/guix/inferior.scm b/guix/inferior.scm index f23d35c9babbda4d68f2abe40fdacdfaf976c71f..89f017c6e86e3f2a68e5ea3ef3b4f5fe7301223a 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