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

From: pinoaffe <[email-masked]>
Date: Thu, 30 Sep 2021 10:17:48 +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

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