From patchwork Thu Feb 25 17:20:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 27307 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E8DC527BC4A; Thu, 25 Feb 2021 17:22:09 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3A2FA27BC4B for ; Thu, 25 Feb 2021 17:22:08 +0000 (GMT) Received: from localhost ([::1]:43396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFKL1-0005UI-Bp for patchwork@mira.cbaines.net; Thu, 25 Feb 2021 12:22:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFKKw-0005UA-FG for guix-patches@gnu.org; Thu, 25 Feb 2021 12:22:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:55831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lFKKw-0007hQ-5q for guix-patches@gnu.org; Thu, 25 Feb 2021 12:22:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lFKKw-0005bh-1s for guix-patches@gnu.org; Thu, 25 Feb 2021 12:22:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46776] [PATCH] inferior: Extend cached-channel-instance scope. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 Feb 2021 17:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46776 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46776@debbugs.gnu.org Cc: Mathieu Othacehe X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161427366721487 (code B ref -1); Thu, 25 Feb 2021 17:22:01 +0000 Received: (at submit) by debbugs.gnu.org; 25 Feb 2021 17:21:07 +0000 Received: from localhost ([127.0.0.1]:39144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFKK2-0005aV-Ta for submit@debbugs.gnu.org; Thu, 25 Feb 2021 12:21:07 -0500 Received: from lists.gnu.org ([209.51.188.17]:44772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFKJz-0005aL-Ux for submit@debbugs.gnu.org; Thu, 25 Feb 2021 12:21:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFKJz-0005IE-Nh for guix-patches@gnu.org; Thu, 25 Feb 2021 12:21:03 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59991) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFKJz-000796-HC for guix-patches@gnu.org; Thu, 25 Feb 2021 12:21:03 -0500 Received: from [2a01:e0a:19b:d9a0:bceb:3bde:446a:14b] (port=32880 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lFKJw-0006rt-3P; Thu, 25 Feb 2021 12:21:02 -0500 From: Mathieu Othacehe Date: Thu, 25 Feb 2021 18:20:48 +0100 Message-Id: <20210225172048.22398-1-othacehe@gnu.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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