Subject: [bug#54539] [PATCH v2 01/30] gnu: package-management: Autoload unless used by Guix.

From: Maxime Devos <[email-masked]>
Date: Sat, 3 Sep 2022 18:43:03 +0200

Goal: reduce the amount of modules that "compute-guix-derivation" needs to
load (reducing memory usage).  As a side benefit, the start-up latency
of various "guix build ..." commands should decrease -- at worst, it should
remain as the same as before.

Delete #:use-module, check that "./pre-inst-env guix build -d guix" still
works. If so, turn the use-module into an #:autoload. If not, reinstate
the #:use-module.  Some imported modules are loaded anyway by dependencies
and as such could theoretically be left intact for the purposes of
<https://issues.guix.gnu.org/54539>, but that's more developer work for no
apparent benefit.

Sometimes, the module wasn't used at all.  In that case, it is removed.

On its own, this commit doesn't accomplish much, so a report will be given
in the latest commit of the series.
---
 gnu/packages/package-management.scm | 155 +++++++++++++++-------------
 1 file changed, 86 insertions(+), 69 deletions(-)

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 519924737c..1c7b90f8c4 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -40,76 +40,93 @@
 (define-module (gnu packages package-management)
   #:use-module (gnu artwork)
   #:use-module (gnu packages)
-  #:use-module (gnu packages acl)
-  #:use-module (gnu packages attr)
-  #:use-module (gnu packages avahi)
-  #:use-module (gnu packages autotools)
-  #:use-module (gnu packages backup)
-  #:use-module (gnu packages base)
-  #:use-module (gnu packages bash)
-  #:use-module (gnu packages bdw-gc)
-  #:use-module (gnu packages bison)
-  #:use-module (gnu packages boost)
+  #:autoload (gnu packages attr) (attr)
+  #:autoload (gnu packages avahi) (avahi)
+  #:use-module (gnu packages autotools) ; required by "guix build -d guix"
+  #:use-module (gnu packages backup) ; required by "guix build -d guix"
+  #:use-module (gnu packages base) ; required by "guix build -d guix"
+  #:autoload (gnu packages bash) (bash-minimal)
+  #:autoload (gnu packages bdw-gc) (libgc)
+  #:autoload (gnu packages bison) (bison)
+  #:autoload (gnu packages boost) (boost)
+  ;; required by "guix build -d guix"
   #:use-module (gnu packages bootstrap)          ;for 'bootstrap-guile-origin'
-  #:use-module (gnu packages build-tools)
-  #:use-module (gnu packages check)
-  #:use-module (gnu packages compression)
-  #:use-module (gnu packages cmake)
-  #:use-module (gnu packages cpio)
-  #:use-module (gnu packages crypto)
-  #:use-module (gnu packages curl)
-  #:use-module (gnu packages databases)
-  #:use-module (gnu packages dejagnu)
-  #:use-module (gnu packages dbm)
-  #:use-module (gnu packages docbook)
-  #:use-module (gnu packages file)
-  #:use-module (gnu packages flex)
-  #:use-module (gnu packages gcc)
-  #:use-module (gnu packages gettext)
-  #:use-module (gnu packages glib)
-  #:use-module (gnu packages gnome)
-  #:use-module (gnu packages gnupg)
-  #:use-module (gnu packages graphviz)
-  #:use-module (gnu packages gtk)
-  #:use-module (gnu packages guile)
-  #:use-module (gnu packages guile-xyz)
-  #:use-module (gnu packages hardware)
-  #:use-module (gnu packages hurd)
-  #:use-module (gnu packages imagemagick)
-  #:use-module (gnu packages less)
-  #:use-module (gnu packages libedit)
-  #:use-module (gnu packages linux)
-  #:use-module (gnu packages lisp)
-  #:use-module (gnu packages lua)
-  #:use-module (gnu packages man)
-  #:use-module (gnu packages markup)
-  #:use-module (gnu packages nettle)
-  #:use-module (gnu packages networking)
-  #:use-module (gnu packages ninja)
-  #:use-module (gnu packages nss)
-  #:use-module (gnu packages patchutils)
-  #:use-module (gnu packages perl)
-  #:use-module (gnu packages perl-check)
-  #:use-module (gnu packages pkg-config)
-  #:use-module (gnu packages popt)
-  #:use-module (gnu packages python)
-  #:use-module (gnu packages python-build)
-  #:use-module (gnu packages python-check)
-  #:use-module (gnu packages python-web)
-  #:use-module (gnu packages python-xyz)
-  #:use-module (gnu packages serialization)
-  #:use-module (gnu packages sqlite)
-  #:use-module (gnu packages ssh)
-  #:use-module (gnu packages tcl)
-  #:use-module (gnu packages texinfo)
-  #:use-module (gnu packages time)
-  #:use-module (gnu packages tls)
-  #:use-module (gnu packages vim)
-  #:use-module (gnu packages virtualization)
-  #:use-module (gnu packages web)
-  #:use-module (gnu packages xml)
-  #:use-module (gnu packages xorg)
-  #:use-module (gnu packages version-control)
+  #:autoload (gnu packages build-tools) (meson)
+  #:autoload (gnu packages check)
+  (googletest python-coverage python-freezegun python-mock python-pytest
+              python-pytest-cov python-pytest-mock  python-pytest-timeout
+              python-parameterized python-pytest-xdist)
+  #:use-module (gnu packages compression) ; required by "guix build -d guix"
+  #:autoload (gnu packages cmake) (cmake)
+  #:autoload (gnu packages cpio) (cpio)
+  #:autoload (gnu packages crypto) (libsodium)
+  #:autoload (gnu packages curl) (curl)
+  #:autoload (gnu packages databases) (sqitch)
+  #:autoload (gnu packages dejagnu) (dejagnu)
+  #:autoload (gnu packages dbm) (bdb)
+  #:autoload (gnu packages docbook) (docbook-xml docbook-xsl)
+  #:autoload (gnu packages file) (file)
+  #:autoload (gnu packages flex) (flex)
+  #:use-module (gnu packages gettext) ; required by "guix build -d guix"
+  #:autoload (gnu packages glib)
+  (glib intltool gobject-introspection dbus appstream-glib xdg-dbus-proxy)
+  #:autoload (gnu packages gnome)
+  (vala libgsf libsoup-minimal-2 dconf json-glib glib-networking
+        gsettings-desktop-schemas)
+  #:use-module (gnu packages gnupg) ; required by "guix build -d guix"
+  #:use-module (gnu packages graphviz) ; required by "guix build -d guix"
+  #:autoload (gnu packages gtk)
+  (guile-rsvg guile-cairo gdk-pixbuf)
+  #:use-module (gnu packages guile) ; required by "guix build -d guix"
+  #:use-module (gnu packages guile-xyz) ; required by "guix build -d guix"
+  #:autoload (gnu packages hardware) (libcpuid)
+  #:use-module (gnu packages hurd) ; required by "guix build -d guix"
+  #:autoload (gnu packages imagemagick) (imagemagick)
+  #:autoload (gnu packages less) (less)
+  #:autoload (gnu packages libedit) (editline)
+  #:use-module (gnu packages linux) ; required by "guix build -d guix"
+  #:autoload (gnu packages lua) (lua)
+  #:use-module (gnu packages man) ; required by "guix build -d guix"
+  #:autoload (gnu packages markup)
+  (lowdown)
+  #:autoload (gnu packages networking)
+  (socat)
+  #:autoload (gnu packages ninja)
+  (ninja)
+  #:autoload (gnu packages nss)
+  (nspr nss)
+  #:autoload (gnu packages perl)
+  (perl perl-capture-tiny perl-io-stringy)
+  #:autoload (gnu packages perl-check)
+  (perl-test-simple perl-test-output)
+  #:use-module (gnu packages pkg-config) ; required by "guix build -d guix"
+  #:autoload (gnu packages popt)
+  (popt)
+  #:autoload (gnu packages python)
+  (python python-wrapper python-3)
+  #:autoload (gnu packages python-build)
+  (python-pyparsing)
+  #:autoload (gnu packages python-web)
+  (python-requests python-responses python-bottle python-urllib3 python-webtest)
+  #:autoload (gnu packages python-xyz)
+  (python-clyent python-nbformat python-pyyaml python-pillow python-six
+                 python-tqdm python-cython python-cytoolz python-pycosat
+                 python-colorama python-distro python-fasteners python-future
+                 python-jinja2 python-node-semver python-patch-ng
+                 python-pluginbase python-pygments python-pyjwt python-pyyaml-5
+                 jupyter python-ipython python-ipykernel)
+  #:autoload (gnu packages serialization) (python-ruamel.yaml)
+  #:use-module (gnu packages sqlite) ; required by "guix build -d guix"
+  #:use-module (gnu packages ssh) ; required by "guix build -d guix"
+  #:autoload (gnu packages tcl) (tcl)
+  #:autoload (gnu packages texinfo) (texinfo)
+  #:autoload (gnu packages time) (python-dateutil python-pytz)
+  #:use-module (gnu packages tls) ; required by "guix build -d guix"
+  #:autoload (gnu packages virtualization) (bubblewrap)
+  #:autoload (gnu packages web) (jq)
+  #:autoload (gnu packages xml) (libxml2 libxslt)
+  #:autoload (gnu packages xorg) (libxau)
+  #:autoload (gnu packages version-control) (git-minimal)
   #:autoload   (guix build-system channel) (channel-build-system)
   #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)

base-commit: 4555fb7dfa08f956bbfc8179772c7288c34b1f97
prerequisite-patch-id: 7626f1464f4926416fb13daf3d846176aa93f51b
prerequisite-patch-id: 445c6f624e99627959f2e54a6ee97337c44d9ea6
prerequisite-patch-id: 7a16c500faec9d58700a2b50b26bded079e9c3ac
prerequisite-patch-id: f7d406c61e069c04c3b7da453192f51c04763db1
prerequisite-patch-id: 4674bf40052d97215f837c9dfd4e7e1ae999492d
-- 
2.37.2