GNU bug report logs -
#50755
[PATCH] import: Generate list of importers based on available modules
Previous Next
To reply to this bug, email your comments to 50755 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Thu, 23 Sep 2021 12:25:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
pinoaffe <pinoaffe <at> airmail.cc>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Thu, 23 Sep 2021 12:25:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* guix/scripts/import.scm (importers): Generate a list of all importers by
looping over available guile modules, allowing for extensibility.
---
guix/scripts/import.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 40fa6759ae..44cbaf13d6 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -23,6 +23,7 @@
(define-module (guix scripts import)
#:use-module (guix ui)
+ #:use-module (guix discovery)
#:use-module (guix scripts)
#:use-module (guix utils)
#:use-module (srfi srfi-1)
@@ -78,9 +79,11 @@ rather than \\n."
;;; Entry point.
;;;
-(define importers '("gnu" "pypi" "cpan" "hackage" "stackage" "egg" "elpa"
- "gem" "go" "cran" "crate" "texlive" "json" "opam"
- "minetest"))
+(define importers (map (lambda (module)
+ (symbol->string (caddr (module-name module))))
+ (all-modules (map (lambda (entry)
+ `(,entry . "guix/import"))
+ %load-path))))
(define (resolve-importer name)
(let ((module (resolve-interface
--
2.32.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Thu, 23 Sep 2021 18:08:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Hello,
This looks like a good improvement! Thanks for submitting the patch.
Just reading ths, I have a couple comments.
pinoaffe <pinoaffe <at> airmail.cc> writes:
> * guix/scripts/import.scm (importers): Generate a list of all importers by
> looping over available guile modules, allowing for extensibility.
> ---
> guix/scripts/import.scm | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> index 40fa6759ae..44cbaf13d6 100644
> --- a/guix/scripts/import.scm
> +++ b/guix/scripts/import.scm
> @@ -23,6 +23,7 @@
>
> (define-module (guix scripts import)
> #:use-module (guix ui)
> + #:use-module (guix discovery)
> #:use-module (guix scripts)
> #:use-module (guix utils)
> #:use-module (srfi srfi-1)
> @@ -78,9 +79,11 @@ rather than \\n."
> ;;; Entry point.
> ;;;
>
> -(define importers '("gnu" "pypi" "cpan" "hackage" "stackage" "egg" "elpa"
> - "gem" "go" "cran" "crate" "texlive" "json" "opam"
> - "minetest"))
> +(define importers (map (lambda (module)
> + (symbol->string (caddr (module-name module))))
Prefer ice-9 'match'/'match-lambda' over 'car'/'cadr'/'caddr'/etc, or if
necessary, SRFI-1 'first', 'second', ..., 'last'.
> + (all-modules (map (lambda (entry)
> + `(,entry . "guix/import"))
should this be guix/scripts/import? ^
> + %load-path))))
>
> (define (resolve-importer name)
> (let ((module (resolve-interface
--
Sarah
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Thu, 23 Sep 2021 21:19:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Hi, thanks for the comments!
Sarah Morgensen writes:
> Prefer ice-9 'match'/'match-lambda' over 'car'/'cadr'/'caddr'/etc, or if
> necessary, SRFI-1 'first', 'second', ..., 'last'.
okay, I'll change this
> should this be guix/scripts/import? ^
It definitely should be, oopsidaisy :)
will send a new patch in a sec
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Thu, 23 Sep 2021 21:20:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 50755 <at> debbugs.gnu.org (full text, mbox):
* guix/scripts/import.scm (importers): Generate a list of all importers by
looping over available guile modules, allowing for extensibility.
---
guix/scripts/import.scm | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 40fa6759ae..ed702d3bff 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -23,6 +23,7 @@
(define-module (guix scripts import)
#:use-module (guix ui)
+ #:use-module (guix discovery)
#:use-module (guix scripts)
#:use-module (guix utils)
#:use-module (srfi srfi-1)
@@ -78,9 +79,14 @@ rather than \\n."
;;; Entry point.
;;;
-(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
--
2.32.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Mon, 27 Sep 2021 14:29:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Hi,
Thanks. Two comments.
On Thu, 23 Sept 2021 at 23:20, pinoaffe <pinoaffe <at> airmail.cc> 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Mon, 27 Sep 2021 18:21:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 50755 <at> debbugs.gnu.org (full text, mbox):
User-agent: mu4e 1.4.15; emacs 27.2
* guix/scripts/import.scm (importers): Generate a list of all importers by
looping over available guile modules, allowing for extensibility.
---
guix/scripts/import.scm | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 40fa6759ae..71ee8cc00b 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -23,6 +23,7 @@
(define-module (guix scripts import)
#:use-module (guix ui)
+ #:use-module (guix discovery)
#:use-module (guix scripts)
#:use-module (guix utils)
#:use-module (srfi srfi-1)
@@ -78,9 +79,15 @@ rather than \\n."
;;; Entry point.
;;;
-(define importers '("gnu" "pypi" "cpan" "hackage" "stackage" "egg" "elpa"
- "gem" "go" "cran" "crate" "texlive" "json" "opam"
- "minetest"))
+(define importers (delete-duplicates
+ (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
--
2.32.0
Date: Mon, 27 Sep 2021 20:20:21 +0200
Message-ID: <87o88dswwq.fsf <at> airmail.cc>
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Mon, 27 Sep 2021 18:28:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Hi,
thank you for your feedback!
zimoun writes:
> First, I think, it breaks "guix import --help". Therefore, this patch
> needs a v3. :-)
I sent a v3, thanks :)
> The question is: which performance loss is acceptable here?
To me a performance loss similar to the one you describe would be
acceptable, particularly since it should be a constant performance hit
for every time ~guix import~ is called, aka it won't significantly
impact long-running import commands. However, I think I may be somewhat
biased on this one, so it'd be great if others could weigh in :)
Kind regards,
pinoaffe
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Mon, 27 Sep 2021 20:10:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Hi,
On Mon, 27 Sept 2021 at 20:21, pinoaffe <pinoaffe <at> airmail.cc> wrote:
> +(define importers (delete-duplicates
This fixes my first point...
> + (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)))))
...and it means it is walking more than needed. Therefore, what is
the performance loss?
For instance, on my machine and hot cache, it is 4x slower. And, this
readibility improvement is not worth, IMHO.
On cold cache, I do not have meaningful numbers because it requires to
run it several times and then compute an average. What are the
numbers of your machine?
All the best,
simon
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Tue, 28 Sep 2021 09:53:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 50755 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
zimoun schreef op ma 27-09-2021 om 22:09 [+0200]:
> Hi,
>
> On Mon, 27 Sept 2021 at 20:21, pinoaffe <pinoaffe <at> airmail.cc> wrote:
>
> > +(define importers (delete-duplicates
>
> This fixes my first point...
>
> > + (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)))))
>
> ...and it means it is walking more than needed. Therefore, what is
> the performance loss?
>
> For instance, on my machine and hot cache, it is 4x slower.
FWIW, calling ./pre-inst-env guix ... will always be slower than guix ...,
because the former will have a longer %load-path (IIRC) and possibly
other reasons.
Using "guix pull --profile=..." "time .../guix import ..." might be a better test.
To only measure the time required for defiing 'importers', wrap delete-duplicates
in a call to 'time' from (ice-9 time).
Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Tue, 28 Sep 2021 14:40:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Hi,
Maxime Devos writes:
> To only measure the time required for defiing 'importers', wrap
> delete-duplicates in a call to 'time' from (ice-9 time).
Running
(time (for-each (lambda (_)
(delete-duplicates (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)))))
(iota 1000)))
in a guix repl on my system results in
clock utime stime cutime cstime gctime
0.96 1.67 0.07 0.00 0.00 1.19
If I'm interpreting that correctly that would amount to a couple of
thousands of a second per run
Kind regards,
pinoaffe
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Wed, 29 Sep 2021 21:00:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 50755 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
pinoaffe schreef op di 28-09-2021 om 16:39 [+0200]:
> Hi,
>
> Maxime Devos writes:
> > To only measure the time required for defiing 'importers', wrap
> > delete-duplicates in a call to 'time' from (ice-9 time).
>
> Running
>
> (time (for-each (lambda (_)
> (delete-duplicates (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)))))
> (iota 1000)))
>
> in a guix repl on my system results in
>
> clock utime stime cutime cstime gctime
> 0.96 1.67 0.07 0.00 0.00 1.19
>
> If I'm interpreting that correctly that would amount to a couple of
> thousands of a second per run
These numbers turn out to be misleading, because 'scheme-modules'
(indirectly called from all-modules) calls 'resolve-interface' on every module
name. For a module name, the first 'resolve-module' incurs disk I/O and some
CPU for loading the module, but the second 'resolve-module' on the same module
name would be free, as the module is already loaded.
Greetings,
Maxime
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Thu, 30 Sep 2021 08:19:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Maxime Devos writes:
> These numbers turn out to be misleading, because 'scheme-modules'
> (indirectly called from all-modules) calls 'resolve-interface' on every module
> name. For a module name, the first 'resolve-module' incurs disk I/O and some
> CPU for loading the module, but the second 'resolve-module' on the same module
> name would be free, as the module is already loaded.
okay, the first incantation of
(time (for-each (lambda (_)
(delete-duplicates (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)))))
(iota 1)))
on a "fresh" guix repl on my system results in
clock utime stime cutime cstime gctime
1.28 0.76 0.13 0.00 0.00 0.16
which is indeed a significant amount of time, though I don't think it'd
be much of an issue considering that it's not likely that users will run
lots of `guix import` shell commands in rapid succession.
kind regards,
pinoaffe
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Thu, 30 Sep 2021 08:38:01 GMT)
Full text and
rfc822 format available.
Message #41 received at 50755 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
pinoaffe schreef op do 30-09-2021 om 10:17 [+0200]:
> Maxime Devos writes:
> > These numbers turn out to be misleading, because 'scheme-modules'
> > (indirectly called from all-modules) calls 'resolve-interface' on every module
> > name. For a module name, the first 'resolve-module' incurs disk I/O and some
> > CPU for loading the module, but the second 'resolve-module' on the same module
> > name would be free, as the module is already loaded.
> okay, the first incantation of
>
> (time (for-each (lambda (_)
> (delete-duplicates (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)))))
> (iota 1)))
>
> on a "fresh" guix repl on my system results in
>
> clock utime stime cutime cstime gctime
> 1.28 0.76 0.13 0.00 0.00 0.16
On my fresh guix repl, it's a bit longer:
clock utime stime cutime cstime gctime
9.54 1.79 0.31 0.00 0.00 0.53
(9 or 10 seconds)
If I restart the guix repl and run it again,
I get about half a second:
clock utime stime cutime cstime gctime
0.47 0.57 0.02 0.00 0.00 0.19
> which is indeed a significant amount of time, though I don't think it'd
> be much of an issue considering that it's not likely that users will run
> lots of `guix import` shell commands in rapid succession.
The list of importers is only needed for two purposes, right?
1. to print a list of importers when "guix import --help" is run
2. to verify the string actually specifies an importer
Then 'guix import SOME-IMPORTER STUFF' could be optimised:
reolve-importer and guix-import could be modified to skip the validation
step and let resolve-importer print the error if the module couldn't be
found. Possibly (resolve-module '(the possibly undefined module) #:ensure #f)
might be useful. Then 'importers' would only be required for purpose (1),
so it could be wrapped in a promise, such that if "guix import some-importer stuff"
is called, only the required importer module is loaded.
Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50755
; Package
guix-patches
.
(Mon, 11 Oct 2021 11:52:01 GMT)
Full text and
rfc822 format available.
Message #44 received at 50755 <at> debbugs.gnu.org (full text, mbox):
Hi,
On Thu, 30 Sept 2021 at 10:37, Maxime Devos <maximedevos <at> telenet.be> wrote:
> The list of importers is only needed for two purposes, right?
>
> 1. to print a list of importers when "guix import --help" is run
> 2. to verify the string actually specifies an importer
>
> Then 'guix import SOME-IMPORTER STUFF' could be optimised:
>
> reolve-importer and guix-import could be modified to skip the validation
> step and let resolve-importer print the error if the module couldn't be
> found. Possibly (resolve-module '(the possibly undefined module) #:ensure #f)
> might be useful. Then 'importers' would only be required for purpose (1),
> so it could be wrapped in a promise, such that if "guix import some-importer stuff"
> is called, only the required importer module is loaded.
My comment is about the elegance vs the performance loss. On old
machines, Guix is becoming unpractical for many operations (almost all
the operations indeed) and I would not add another slowness. I am
fine to sacrifice some performances if it is worth. However, the
balance is always: what is gain and what is loss? Here the gain is
small code elegance against the performance lost for end-user. The
question: does it worth? From my point of view, no, this change is
not worth. For what my opinion is worth here. ;-)
Cheers,
simon
This bug report was last modified 3 years and 245 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.