Subject: Re: [bug#50755] [PATCH v2] import: Generate list of importers based on available modules

From: zimoun <[email-masked]>
Date: Mon, 27 Sep 2021 16:28:30 +0200

Hi,

Thanks.  Two comments.

On Thu, 23 Sept 2021 at 23:20, pinoaffe <[email-masked]> wrote:

> -(define importers '("gnu" "pypi" "cpan" "hackage" "stackage" "egg" "elpa"
> -                    "gem" "go" "cran" "crate" "texlive" "json" "opam"
> -                    "minetest"))
> +(define importers (filter-map (lambda (module)
> +                                (match (module-name module)
> +                                  (`(guix scripts import ,importer)
> +                                   (symbol->string importer))
> +                                  ( #t #f)))
> +                              (all-modules (map (lambda (entry)
> +                                                  `(,entry . "guix/scripts/import"))
> +                                                %load-path))))
>
>  (define (resolve-importer name)
>    (let ((module (resolve-interface

First, I think, it breaks "guix import --help".  Therefore, this patch
needs a v3. :-)

Second, what is the average extra time added on cold cache?  On my
machine, for hot cache, I get:

--8<---------------cut here---------------start------------->8---
$ time guix import cran -h

real    0m0.113s
user    0m0.110s
sys    0m0.025s

$ time ./pre-inst-env guix import cran -h

real    0m0.470s
user    0m0.529s
sys    0m0.054s
--8<---------------cut here---------------end--------------->8---

which is something.  On cold cache, it is:

real    0m10.438s
user    0m0.164s
sys    0m0.082s

vs

real    0m12.226s
user    0m0.897s
sys    0m0.190s

but these numbers are not so much meaningful because there is a strong
variability; hence on average. :-)

Because of 'filter-map', it walks all the modules, so there is a
performance loss.  The question is: which performance loss is
acceptable here?
Other said, is the code improvement worth compared to the performance decrease?

All the best,
simon