diff mbox series

[bug#70132,05/11] channels: Autoload (git …) modules.

Message ID b8b31c5056e8e01990e7ce22d1c07aaced22ec76.1712002698.git.ludo@gnu.org
State New
Headers show
Series Improve startup time and memory footprint for short-lived commands | expand

Commit Message

Ludovic Courtès April 1, 2024, 8:25 p.m. UTC
Autoloading Guile-Git is important in cases where (guix channels) is
used for little more than the <channel> definition.  This is the case,
for example, of ‘guix describe’ or ‘guix shell’.

This reduces from 177 to 121 the number of .go files loaded when
running:

  ./pre-inst-env strace -e openat -o /tmp/log.strace \
     guix describe -p /var/guix/profiles/per-user/$USER/current-guix
  grep 'openat.*\.go.* = [0-9]' < /tmp/log.strace |wc -l

Likewise, it reduces the max RSS (as measured by ‘time -f %M guix
describe -p …’) from 54 to 37 MiB.

* guix/channels.scm: Autoload (git …) modules.

Change-Id: Ia58a99c865bf0f6fe461a1e71390d075e760f8d6
---
 guix/channels.scm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Simon Tournier April 15, 2024, 10:45 p.m. UTC | #1
Hi,

On lun., 01 avril 2024 at 22:25, Ludovic Courtès <ludo@gnu.org> wrote:
> Autoloading Guile-Git is important in cases where (guix channels) is
> used for little more than the <channel> definition.  This is the case,
> for example, of ‘guix describe’ or ‘guix shell’.
>
> This reduces from 177 to 121 the number of .go files loaded when
> running:
>
>   ./pre-inst-env strace -e openat -o /tmp/log.strace \
>      guix describe -p /var/guix/profiles/per-user/$USER/current-guix
>   grep 'openat.*\.go.* = [0-9]' < /tmp/log.strace |wc -l
>
> Likewise, it reduces the max RSS (as measured by ‘time -f %M guix
> describe -p …’) from 54 to 37 MiB.
>
> * guix/channels.scm: Autoload (git …) modules.
>
> Change-Id: Ia58a99c865bf0f6fe461a1e71390d075e760f8d6
> ---
>  guix/channels.scm | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/guix/channels.scm b/guix/channels.scm
> index 70608561f9..51024dcad4 100644
> --- a/guix/channels.scm
> +++ b/guix/channels.scm
> @@ -20,7 +20,13 @@
>  ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
>  
>  (define-module (guix channels)
> -  #:use-module (git)                              ;TODO: autoload
> +  #:autoload   (git commit) (commit-lookup
> +                             commit-id)
> +  #:autoload   (git oid) (oid->string
> +                          string->oid)
> +  #:autoload   (git object) (object-id)
> +  #:autoload   (git errors) (GIT_ENOTFOUND)
> +  #:autoload   (git structs) (git-error-code)
>    #:autoload   (guix git) (update-cached-checkout
>                             url+commit->name
>                             commit-difference

Oh!  Awesome!!  Thanks for the tricks.

Cheers,
simon
diff mbox series

Patch

diff --git a/guix/channels.scm b/guix/channels.scm
index 70608561f9..51024dcad4 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -20,7 +20,13 @@ 
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix channels)
-  #:use-module (git)                              ;TODO: autoload
+  #:autoload   (git commit) (commit-lookup
+                             commit-id)
+  #:autoload   (git oid) (oid->string
+                          string->oid)
+  #:autoload   (git object) (object-id)
+  #:autoload   (git errors) (GIT_ENOTFOUND)
+  #:autoload   (git structs) (git-error-code)
   #:autoload   (guix git) (update-cached-checkout
                            url+commit->name
                            commit-difference