From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cGYfCsLcN2AGYQAA0tVLHw (envelope-from ) for ; Thu, 25 Feb 2021 17:22:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id rKLzBcLcN2BoRgAA1q6Kng (envelope-from ) for ; Thu, 25 Feb 2021 17:22:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 578232571D for ; Thu, 25 Feb 2021 18:22:09 +0100 (CET) Received: from localhost ([::1]:43396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFKL2-0005UI-3F for larch@yhetil.org; Thu, 25 Feb 2021 12:22:08 -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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 2.13 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 578232571D X-Spam-Score: 2.13 X-Migadu-Scanner: scn1.migadu.com X-TUID: s/Juqybn20U+ * 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