[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Transform: walk through packages
From: |
zimoun |
Subject: |
Transform: walk through packages |
Date: |
Sat, 11 Sep 2021 14:09:52 +0200 |
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