Subject: [bug#39258] [PATCH v6 1/2] DRAFT packages: Add fields to packages cache.

From: zimoun <[email-masked]>
Date: Tue, 17 Aug 2021 16:03:17 +0200

Hi Arun and Ludo,

Thanks for the review.

On Sat, 17 Jul 2021 at 14:01, Arun Isaac <[email-masked]> wrote:

> I understand that one of the things you are trying to do is to have a
> common interface for the cache and no-cache cases. To achieve this, I
> think fold-available-packages and fold-packages should have the same
> function signature. They should both pass a <package> object to
> PROC. Currently, fold-packages is passing a <package> object whereas
> fold-available-packages is passing the fields of the <package> object as
> individual parameters. If fold-packages and fold-available-packages have
> the same function signature, then the changes in your [PATCH v6 2/2]
> would be way simpler.

I agree.  Previously [1], I created ’fold-packages*’ which was a cached
’fold-packages’ and Ludo answered [2]:

        Did you see ‘fold-available-packages’?  It seems you could
        extend it instead of introducing ‘fold-packages*’, no?

therefore, it is somehow another attempt on the other side. :-)

1: <http://issues.guix.gnu.org/39258#91>
2: <http://issues.guix.gnu.org/39258#93>

> Also, why do we need two separate functions---fold-available-packages
> and fold-packages? Can't fold-available-packages do everything
> fold-packages can and thus totally replace it?

To be honest, I have been lazy because unifying
’fold-available-packages’ and ’fold-packages’ means to change the
signature and so a bit of refactoring.  And as Ludo explained,
’fold-available-packages’ has to be as light as possible because it is
used by Emacs-Guix and maybe Nyxt for completion. :-)

>> * gnu/packages.scm (generate-package-cache)[expand-cache]: Add synopsis and
>> description.
>> (load-package-cache, find-packages-by-names, find-packages-locations): Adapt
>> accordingly.
>
> A couple of typos here:
>
> find-packages-by-names -> find-packages-by-name
> find-packages-locations -> find-package-locations

Thanks for the spot.

On Fri, 23 Jul 2021 at 17:30, Ludovic Courtès <[email-masked]> wrote:

> One benchmark is “guix package -A > /dev/null”.  This should take
> ideally 0.5s at most because that’s what’s used by shell completion (the
> first time); currently it takes 0.82s on my laptop, though.

On cold cache, on my laptop:

--8<---------------cut here---------------start------------->8---
$ time guix package -A > /dev/null

real	0m1.717s
user	0m2.526s
sys	0m0.083s
--8<---------------cut here---------------end--------------->8---

and on my (slow) desktop:

real	0m6.196s
user	0m2.008s
sys	0m0.093s

Warn cache:
        laptop          desktop
real	0m1.425s        0m1.217s
user	0m2.505s   	0m1.901s
sys	0m0.033s   	0m0.051s

Well, another story I guess. :-)

Cheers,
simon