From unknown Sat Jun 21 17:35:44 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#73674 <73674@debbugs.gnu.org> To: bug#73674 <73674@debbugs.gnu.org> Subject: Status: [PATCH] shell: Enable caching when using deterministic package transformations. Reply-To: bug#73674 <73674@debbugs.gnu.org> Date: Sun, 22 Jun 2025 00:35:44 +0000 retitle 73674 [PATCH] shell: Enable caching when using deterministic packag= e transformations. reassign 73674 guix-patches submitter 73674 Ludovic Court=C3=A8s severity 73674 normal tag 73674 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 07 04:36:22 2024 Received: (at submit) by debbugs.gnu.org; 7 Oct 2024 08:36:22 +0000 Received: from localhost ([127.0.0.1]:44690 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxjE5-0005LU-Hz for submit@debbugs.gnu.org; Mon, 07 Oct 2024 04:36:22 -0400 Received: from lists.gnu.org ([209.51.188.17]:34290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxjE3-0005LK-3i for submit@debbugs.gnu.org; Mon, 07 Oct 2024 04:36:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxjDt-0005c7-HA for guix-patches@gnu.org; Mon, 07 Oct 2024 04:36:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxjDs-0006KN-1y; Mon, 07 Oct 2024 04:36:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=gCzNbjZP/QQ2aJE4Vq7CLBVDqsZWk6vssDafT3ei0qY=; b=dCgr6cwltsj1jk r2M9VD6ZJAaID3vQ6jtITZLH6p/1mZnSYI1Z9KuGmz9+1ML0QrGHVlNW4aIdxKqERD6wvUwHRY0zo 5HgOJWzewrVuuEKhlpshqYpE4bC3ssZ1kXwVeIqdqEW+h7Jw2GZOosjcAydzi5sIYcGOqK9jNgiGa SN78XQgx7yLmULhBa0upqpR/Bnp3OUinnvNdDDFL55hux66iA4Q54JVe0I/lrQZFVUgLi41K/mxYO Db7mhCh/fB1Uyo7tKVx4bsQ+8kQ7dGbGVXMy3eY17TWFpUixNyjGjF4EzFRXYeSJOblexGwCT52BO Vhv6q2sIgSCaAm6XbDqg==; From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH] shell: Enable caching when using deterministic package transformations. Date: Mon, 7 Oct 2024 10:35:55 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Debbugs-Cc: Christopher Baines , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès Until now, using any package transformation would disable the automatic GC root creation and caching in ‘guix shell’. This change introduces a finer-grain distinction: a command like: guix shell --tune inkscape is now subject to caching, whereas: guix shell --with-latest=inkscape inkscape remains non-cacheable. * guix/transformations.scm (%transformations-with-external-dependencies): New variable. (cacheable-transformation-option-key?): New procedure. * guix/scripts/shell.scm (profile-cached-gc-root): In the ‘transformation-option-key?’ clause, call ‘loop’ when ‘cacheable-transformation-option-key?’ returns true. Change-Id: I847b661dfea20ecf851db2023a5c7ea8c5b5ca7c --- guix/scripts/shell.scm | 13 ++++++++----- guix/transformations.scm | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index 0584a7e018..d23362a15d 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2021-2023 Ludovic Courtès +;;; Copyright © 2021-2024 Ludovic Courtès ;;; Copyright © 2023 Janneke Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. @@ -25,6 +25,7 @@ (define-module (guix scripts shell) show-native-build-options-help) #:autoload (guix transformations) (options->transformation transformation-option-key? + cacheable-transformation-option-key? show-transformation-options-help) #:autoload (guix grafts) (%graft?) #:use-module (guix scripts) @@ -417,11 +418,13 @@ (define (profile-cached-gc-root opts) ;; Arbitrary expressions might be non-deterministic or otherwise depend ;; on external state so do not cache when they're used. (values #f #f)) - ((((? transformation-option-key?) . _) . _) + ((((? transformation-option-key? key) . _) . rest) ;; Transformation options are potentially "non-deterministic", or at - ;; least depending on external state (with-source, with-commit, etc.), - ;; so do not cache anything when they're used. - (values #f #f)) + ;; least depending on external state (with-source, with-commit, etc.). + ;; Cache only those that are known to be "cacheable". + (if (cacheable-transformation-option-key? key) + (loop rest system file (cons (first opts) specs)) + (values #f #f))) ((('profile . _) . _) ;; If the user already specified a profile, there's nothing more to ;; cache. diff --git a/guix/transformations.scm b/guix/transformations.scm index 582f8a2729..ea8b7a0844 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016-2023 Ludovic Courtès +;;; Copyright © 2016-2024 Ludovic Courtès ;;; Copyright © 2021 Marius Bakke ;;; Copyright © 2023 Sarthak Shah ;;; Copyright © 2023, 2024 Efraim Flashner @@ -63,6 +63,7 @@ (define-module (guix transformations) show-transformation-options-help transformation-option-key? + cacheable-transformation-option-key? %transformation-options)) ;;; Commentary: @@ -938,6 +939,16 @@ (define %transformations (with-latest . ,transform-package-latest) (with-version . ,transform-package-version))) +(define %transformations-with-external-dependencies + ;; Subset of options that depend on external resources and that can thus be + ;; considered "non-deterministic" and non-cacheable. + '(with-source + with-branch + with-git-url + with-patch + with-latest + with-version)) + (define (transformation-procedure key) "Return the transformation procedure associated with KEY, a symbol such as 'with-source', or #f if there is none." @@ -952,6 +963,13 @@ (define (transformation-option-key? key) For example, (transformation-option-key? 'with-input) => #t." (->bool (transformation-procedure key))) +(define (cacheable-transformation-option-key? key) + "Return true if KEY corresponds to a transformation option whose result can +be cached--i.e., the transformation is deterministic and does not depend on +external resources." + (and (transformation-option-key? key) + (not (memq key %transformations-with-external-dependencies)))) + ;;; ;;; Command-line handling. base-commit: 73ec844389e91cb0f5a2647070516fc8d19d8730 -- 2.46.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 21 18:31:19 2024 Received: (at 73674-done) by debbugs.gnu.org; 21 Oct 2024 22:31:19 +0000 Received: from localhost ([127.0.0.1]:53867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t30vm-00026O-RD for submit@debbugs.gnu.org; Mon, 21 Oct 2024 18:31:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t30vl-00026B-8Q for 73674-done@debbugs.gnu.org; Mon, 21 Oct 2024 18:31:17 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t30vE-0003mG-Tq; Mon, 21 Oct 2024 18:30:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=McOendSCuo/eZf5zcQTTv/LqHicJfbD3xNQv2jQ3i4k=; b=ExoSWiCE8JOEmdZ+GEu6 MLx7KQc423o4v9BBOJQ7ueRBoIiUENQqvA8I8J3dM/lgAMWMieW/B7KBFKxTWzthMJ5eKih3r6x2f RiF+TCWFDYjD3odp8Js8GwJtjoxkj0NY/MpUCUfq8f2Z4Aoyw+s3HeCxntHG99I3mSJVQSF/PlPdq xU1YInK4HERPi4n47d0FiulG3nOeCYq2QfCcZ0hF7dE6yn6TepWpF2rZnkcWVgHhRrKHnZ0EQ9cdt RcXG3z3rD3kfjo4Z24odmdfckyori8VrJXfTdfBhjqPJsYc5Loapb/b1N6s+50Kw3Ggu3FfWHWxA+ iAO0RTCEwoSSTA==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 73674-done@debbugs.gnu.org Subject: Re: [bug#73674] [PATCH] shell: Enable caching when using deterministic package transformations. In-Reply-To: ("Ludovic =?utf-8?Q?Court=C3=A8s=22's?= message of "Mon, 7 Oct 2024 10:35:55 +0200") References: Date: Tue, 22 Oct 2024 00:30:41 +0200 Message-ID: <87bjzdccmm.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73674-done Cc: Tobias Geerinckx-Rice , Christopher Baines , Josselin Poiret , Simon Tournier , Mathieu Othacehe X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ludovic Court=C3=A8s skribis: > From: Ludovic Court=C3=A8s > > Until now, using any package transformation would disable the automatic > GC root creation and caching in =E2=80=98guix shell=E2=80=99. This chang= e introduces a > finer-grain distinction: a command like: > > guix shell --tune inkscape > > is now subject to caching, whereas: > > guix shell --with-latest=3Dinkscape inkscape > > remains non-cacheable. > > * guix/transformations.scm (%transformations-with-external-dependencies): > New variable. > (cacheable-transformation-option-key?): New procedure. > * guix/scripts/shell.scm (profile-cached-gc-root): In the > =E2=80=98transformation-option-key?=E2=80=99 clause, call =E2=80=98loop= =E2=80=99 when > =E2=80=98cacheable-transformation-option-key?=E2=80=99 returns true. > > Change-Id: I847b661dfea20ecf851db2023a5c7ea8c5b5ca7c I went ahead and pushed it as 6d8107c967a554e23b0c58c8933894d4468ad596. Ludo=E2=80=99. From unknown Sat Jun 21 17:35:44 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 19 Nov 2024 12:24:21 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator