guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/06: ui: Have 'guix help' stat less.


From: guix-commits
Subject: 03/06: ui: Have 'guix help' stat less.
Date: Mon, 28 Jun 2021 18:04:58 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit ab37731a8d51d968508dda85f1f434f0d3369055
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Jun 28 22:52:16 2021 +0200

    ui: Have 'guix help' stat less.
    
    This reduces the number of syscalls for:
    
      env -i $(type -P strace) -c $(type -P guix) help
    
    from 4.3K to 2.2K, thereby reducing startup time.
    
    Reported by Julien Lepiller.
    
    * guix/ui.scm (run-guix-command): Move %FILE-PORT-NAME-CANONICALIZATION
    to...
    (run-guix): ... here.
---
 guix/ui.scm | 64 ++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index d3e01f8..26a437e 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2139,16 +2139,14 @@ found."
   (let ((command-main (module-ref module
                                   (symbol-append 'guix- command))))
     (parameterize ((program-name command))
-      ;; Disable canonicalization so we don't don't stat unreasonably.
-      (with-fluids ((%file-port-name-canonicalization #f))
-        (dynamic-wind
-          (const #f)
-          (lambda ()
-            (apply command-main args))
-          (lambda ()
-            ;; Abuse 'exit-hook' (which is normally meant to be used by the
-            ;; REPL) to run things like profiling hooks upon completion.
-            (run-hook exit-hook)))))))
+      (dynamic-wind
+        (const #f)
+        (lambda ()
+          (apply command-main args))
+        (lambda ()
+          ;; Abuse 'exit-hook' (which is normally meant to be used by the
+          ;; REPL) to run things like profiling hooks upon completion.
+          (run-hook exit-hook))))))
 
 (define (run-guix . args)
   "Run the 'guix' command defined by command line ARGS.
@@ -2160,28 +2158,30 @@ and signal handling have already been set up."
   ;; number of 'stat' calls per entry in %LOAD-PATH.  Shamelessly remove it.
   (set! %load-extensions '(".scm"))
 
-  (match args
-    (()
-     (format (current-error-port)
-             (G_ "guix: missing command name~%"))
-     (show-guix-usage))
-    ((or ("-h") ("--help"))
-     (leave-on-EPIPE (show-guix-help)))
-    ((or ("-V") ("--version"))
-     (show-version-and-exit "guix"))
-    (((? option? o) args ...)
-     (format (current-error-port)
-             (G_ "guix: unrecognized option '~a'~%") o)
-     (show-guix-usage))
-    (("help" command)
-     (apply run-guix-command (string->symbol command)
-            '("--help")))
-    (("help" args ...)
-     (leave-on-EPIPE (show-guix-help)))
-    ((command args ...)
-     (apply run-guix-command
-            (string->symbol command)
-            args))))
+  ;; Disable canonicalization so we don't don't stat unreasonably.
+  (with-fluids ((%file-port-name-canonicalization #f))
+    (match args
+      (()
+       (format (current-error-port)
+               (G_ "guix: missing command name~%"))
+       (show-guix-usage))
+      ((or ("-h") ("--help"))
+       (leave-on-EPIPE (show-guix-help)))
+      ((or ("-V") ("--version"))
+       (show-version-and-exit "guix"))
+      (((? option? o) args ...)
+       (format (current-error-port)
+               (G_ "guix: unrecognized option '~a'~%") o)
+       (show-guix-usage))
+      (("help" command)
+       (apply run-guix-command (string->symbol command)
+              '("--help")))
+      (("help" args ...)
+       (leave-on-EPIPE (show-guix-help)))
+      ((command args ...)
+       (apply run-guix-command
+              (string->symbol command)
+              args)))))
 
 (define (guix-main arg0 . args)
   (initialize-guix)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]