From: "Ludovic Courtès" <ludo@gnu.org>
To: 27162@debbugs.gnu.org
Subject: bug#27162: [PATCH 1/6] derivations: 'substitution-oracle' returns a <substitutable>.
Date: Wed, 31 May 2017 15:51:54 +0200 [thread overview]
Message-ID: <20170531135159.8186-1-ludo@gnu.org> (raw)
In-Reply-To: <20170531134941.8012-1-ludo@gnu.org>
* guix/derivations.scm (substitution-oracle): Use
'substitution-path-info' instead of 'substitution-paths'. Turn SUBST
into a vhash from path to <substitutable>. Change the returned
procedure to provide a <substitutable> instead of a Boolean.
* tests/derivations.scm ("substitution-oracle and #:substitute? #f"):
Mock 'substitutable-path-info' instead of 'substitutable-paths'.
---
guix/derivations.scm | 16 ++++++++++++----
tests/derivations.scm | 2 +-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/guix/derivations.scm b/guix/derivations.scm
index 9aaab05ec..5e457f189 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -271,13 +271,14 @@ result is the set of prerequisites of DRV not already in valid."
(define* (substitution-oracle store drv
#:key (mode (build-mode normal)))
"Return a one-argument procedure that, when passed a store file name,
-returns #t if it's substitutable and #f otherwise. The returned procedure
+returns a 'substitutable?' if it's substitutable and #f otherwise.
+The returned procedure
knows about all substitutes for all the derivations listed in DRV, *except*
those that are already valid (that is, it won't bother checking whether an
item is substitutable if it's already on disk); it also knows about their
prerequisites, unless they are themselves substitutable.
-Creating a single oracle (thus making a single 'substitutable-paths' call) and
+Creating a single oracle (thus making a single 'substitutable-path-info' call) and
reusing it is much more efficient than calling 'has-substitutes?' or similar
repeatedly, because it avoids the costs associated with launching the
substituter many times."
@@ -318,8 +319,15 @@ substituter many times."
(cons* self (dependencies drv) result)))))
'()
drv))))
- (subst (list->set (substitutable-paths store paths))))
- (cut set-contains? subst <>)))
+ (subst (fold (lambda (subst vhash)
+ (vhash-cons (substitutable-path subst) subst
+ vhash))
+ vlist-null
+ (substitutable-path-info store paths))))
+ (lambda (item)
+ (match (vhash-assoc item subst)
+ (#f #f)
+ ((key . value) value)))))
(define* (derivation-prerequisites-to-build store drv
#:key
diff --git a/tests/derivations.scm b/tests/derivations.scm
index cabbf7b95..d4e1a32bb 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -919,7 +919,7 @@
(set! query paths)
'())
- (mock ((guix store) substitutable-paths
+ (mock ((guix store) substitutable-path-info
record-substitutable-path-query)
(let ((pred (substitution-oracle store (list drv))))
--
2.13.0
next prev parent reply other threads:[~2017-05-31 13:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 13:49 bug#27162: [PATCH 0/6] Display how much will be downloaded Ludovic Courtès
2017-05-31 13:51 ` Ludovic Courtès [this message]
2017-05-31 13:51 ` bug#27162: [PATCH 2/6] derivations: 'derivation-prerequisites-to-build' returns <substitutable> Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 3/6] ui: 'show-what-to-build' displays how much will be downloaded Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 4/6] syscalls: Provide 'free-disk-space' Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 5/6] ui: 'show-what-to-build' warns when we don't have enough disk space Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 6/6] substitute: Do not display the installed size Ludovic Courtès
2017-05-31 19:42 ` bug#27162: [PATCH 0/6] Display how much will be downloaded Maxim Cournoyer
2017-05-31 20:48 ` Ludovic Courtès
2017-05-31 21:39 ` Danny Milosavljevic
2017-05-31 22:02 ` Maxim Cournoyer
2017-06-02 16:49 ` Ludovic Courtès
2017-06-01 11:19 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170531135159.8186-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=27162@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.