unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Nikita Karetnikov <nikita@karetnikov.org>
Cc: guix-devel@gnu.org
Subject: Re: Proposal: prefetch tarballs in a batch
Date: Fri, 25 Apr 2014 14:04:24 +0200	[thread overview]
Message-ID: <874n1haa47.fsf@gnu.org> (raw)
In-Reply-To: <871twmo25m.fsf@karetnikov.org> (Nikita Karetnikov's message of "Fri, 25 Apr 2014 01:20:21 +0400")

I forgot to comment on the actual patch...

Nikita Karetnikov <nikita@karetnikov.org> skribis:

> +(define (fold-values f acc seen lst)

Use ‘fold2’ from (guix utils) instead.

> +(define (derivations-to-prefetch store drv)
> +  "Return the list of fixed-output derivations that DRV depends on, directly
> +or indirectly."
> +  (define (unique-derivations acc seen lst)
> +    ;; Return two values: the list of unique fixed-output derivations and the
> +    ;; list of seen derivations.
> +    (fold-values (lambda (acc seen drv-input)
> +                   (let ((drv* (call-with-input-file (derivation-input-path drv-input)
> +                                 read-derivation)))
> +                     (cond ((fixed-output-derivation? drv*)
> +                            (values (lset-adjoin equal? acc drv*)
> +                                    seen))
> +                           ((member drv* seen)
> +                            (values acc seen))
> +                           (else
> +                            (unique-derivations acc
> +                                                (cons drv* seen)
> +                                                (derivation-inputs drv*))))))
> +                 acc
> +                 seen
> +                 lst))
> +
> +  (identity  ; discard the second value
> +   (unique-derivations '() '() (derivation-inputs drv))))

Can’t it be simplified along these lines:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (define (derivation-input->derivation input) 
		       (call-with-input-file (derivation-input-path input)
			 read-derivation))
scheme@(guile-user)> (filter fixed-output-derivation?
			     (map derivation-input->derivation (derivation-prerequisites $6)))
$10 = (#<derivation /gnu/store/slmkaqybzszjxbl78ymp1dn9c79m9kmy-linux-libre-3.3.8-gnu.tar.xz.drv => /gnu/store/zgh2nvvxkwvmijchf4gyrqb4cq11znvd-linux-libre-3.3.8-gnu.tar.xz 3cbc2d0> #<derivation /gnu/store/c41c2g3g54ipwf5ja3wip5wc...
--8<---------------cut here---------------end--------------->8---

> +;; XXX: remove me.
> +(define specification->package+output
> +  (@@ (guix scripts package) specification->package+output))

I think ‘specification->package’ from (guix scripts build) should be
used instead (it can be exported from there), because the output part of
the specification isn’t needed here: it would make no sense to type

  guix prefetch glibc:debug

because the source of glibc:debug is the same as that of glibc.

> +  (let ((opts  (parse-options))
> +        (store (open-connection)))
> +    (map (lambda (package)
> +           (format #t "Prefetching the derivations for '~a':~%"
> +                   (package-name package))
> +
> +           (build-derivations
> +            store
> +            (map (lambda (drv)
> +                   ;; (format #t "   ~a~%" (derivation-file-name drv))
> +                   (format #t "   ~a~%" drv)
> +                   drv)
> +                 (derivations-to-prefetch
> +                  store
> +                  (package-derivation store package)))))
> +
> +         (delete-duplicates
> +          (filter-map (match-lambda
> +                       (('argument . value)
> +                        (identity  ; discard the second value
> +                         ;; Check that all VALUEs in the list are valid
> +                         ;; packages before calling 'derivations-to-prefetch'.
> +                         ;; If VALUE is not a valid package,
> +                         ;; 'specification->package+output' will raise an
> +                         ;; error.
> +                         (specification->package+output value)))
> +                       (_ #f))
> +                      (reverse opts))))))

It should be a single ‘build-derivations’ call, to allow for
parallelism.

Thanks!

Ludo’.

  parent reply	other threads:[~2014-04-25 12:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-27 23:25 Proposal: prefetch tarballs in a batch Nikita Karetnikov
2014-03-28 13:23 ` Ludovic Courtès
2014-04-01 23:23   ` Nikita Karetnikov
2014-04-02 12:57     ` Ludovic Courtès
2014-04-02 22:37       ` Nikita Karetnikov
2014-04-03  7:24         ` Ludovic Courtès
2014-04-09 22:29           ` Nikita Karetnikov
2014-04-10  8:21             ` Ludovic Courtès
2014-04-12 20:19               ` Nikita Karetnikov
2014-04-12 22:44                 ` Ludovic Courtès
2014-04-24 21:20                   ` Nikita Karetnikov
2014-04-25 11:51                     ` Ludovic Courtès
2014-04-25 12:04                     ` Ludovic Courtès [this message]
2014-05-06 12:37                       ` Nikita Karetnikov
2014-05-06 20:02                         ` Ludovic Courtès
2014-05-07 23:14                           ` Nikita Karetnikov
2014-05-08 16:35                             ` Ludovic Courtès
2014-05-11 14:52                               ` Nikita Karetnikov
2014-05-11 19:17                                 ` Ludovic Courtès
2014-09-02 21:06                                   ` Ludovic Courtès
2014-09-02 22:05                                     ` Nikita Karetnikov
2014-09-02 21:04                               ` 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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874n1haa47.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=nikita@karetnikov.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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).