unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: zimoun <zimon.toutoune@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: "guix-devel@gnu.org" <guix-devel@gnu.org>
Subject: Transform: walk through packages
Date: Sat, 11 Sep 2021 14:09:52 +0200	[thread overview]
Message-ID: <86k0jnb9f3.fsf@gmail.com> (raw)
In-Reply-To: <8735qe23el.fsf@gnu.org>

Hi,

The initial message [1] leads to various questions about
transformations:

  1) optimize the walk
  2) check if the transformation makes sense or not.
  3) apply a transformation to a non-existent package,

The #2 is commented in this subthread [2].  The #3 is addressed with the
draft patch attached [3].  Here, let comment about #1.

1: <https://lists.gnu.org/archive/html/guix-devel/2021-08/msg00072.html>
2: <https://lists.gnu.org/archive/html/guix-devel/2021-09/msg00110.html>
3: <https://lists.gnu.org/archive/html/guix-devel/2021-09/msg00022.html>

On Wed, 08 Sep 2021 at 22:55, Ludovic Courtès <ludo@gnu.org> wrote:
> zimoun <zimon.toutoune@gmail.com> skribis:

>> Last, speaking about transformations, the graph is walked too much
>> when several transformations is applied:
>>
>>    guix build hello --with-latest=foo --with-input=bar=baz --with-latest=chouib
>>
>> then the graph is walked 3 times, IIUC.  The options needs a rewrite
>> to pass a list of specs to 'package-with-latest-upstream' and not
>> twice a list with only one element.  This would reduce to 2 walks.
>> Then it could be nice to compose the transformation and then walk only
>> once (apply 'package-mapping' only once).
>> Well, maybe I miss something.
>
> Right, I guess it could work.  It’s the same complexity anyway, but at
> least it would lower the constant costs.

Yeah, for sure.  But for example, if you go to 5 shops, buy stuff, put
in your bag, you will not first go to each and just pay then second go
again to each and bring the stuff.  It is the same complexity in term of
number of shops, though. ;-)

I do not know the Guile internals so maybe I miss a point.  From my
understanding, this pattern is odd:

   (map f (map g xs))

and instead it seems better:

  (map (compose f g) xs)

The “visible” effect of the win of the factor 2 in the constant costs
depends on the constant costs of f and g vs the constant cost to walk
the list.  But still, there is a factor 2 win. :-)

For instance, GHC has a rewrite rule [4] pass for automatic optimization
when compiling. :-)

4: <https://downloads.haskell.org/~ghc/6.12.2/docs/html/users_guide/rewrite-rules.html>


Anyway.  From the previous example, it appears to me easy to group the
transform ’--with-latest’ and applies a list of 2 elements.  It is
somehow a list arrangement in ’applicable’ and then each transform
already accepts a list of specs.  I will try to come up with a patch if
no one beats me. :-)

However, I do not know beforehand if all the transformations
(e.g., --with-latest and --with-input) will compose well.

Well, it is an investigation of this comment. ;-)

                     (transform
                      ;; XXX: We used to pass TRANSFORM a list of several
                      ;; arguments, but we now pass only one, assuming that
                      ;; transform composes well.

Cheers,
simon


  parent reply	other threads:[~2021-09-11 12:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  3:57 Transform options should error on nonexistant targets Ryan Prior
2021-08-25 16:16 ` zimoun
2021-09-02 10:06   ` Ludovic Courtès
2021-09-02 10:50     ` zimoun
2021-09-08 20:55       ` Ludovic Courtès
2021-09-08 22:29         ` Transform options: check if applied or not zimoun
2021-09-09 10:32           ` Maxime Devos
2021-09-11 12:09         ` zimoun [this message]
2021-09-17  8:57         ` Transform options should error on nonexistant targets zimoun

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=86k0jnb9f3.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@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 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).