diff options
author | Ludovic Courtès <ludo@gnu.org> | 2021-12-15 12:45:11 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-12-15 17:12:13 +0100 |
commit | 2a621f168faec09be7ed3f6b9351c24a472b19e4 (patch) | |
tree | 2e7d7e22057d5d73d9a3323426f1246524415d15 /guix/scripts | |
parent | ebbf7fc1c65d3c5e85ad7cfeef1fb9d73deb9195 (diff) |
offload: Autoload Guile-SSH.
This halves the number of syscalls made by "guix offload" during startup
and delays loading of Guile-SSH until there are actually machines to
offload to.
* guix/scripts/offload.scm: Remove unused module imports. Autoload many
modules.
(check-ssh-zlib-support): New procedure.
(process-request): Call it when accepting.
(guix-offload): Remove 'zlib-support?' check, now moved to
'check-ssh-zlib-support'.
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/offload.scm | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index 29c3f5ec65..9ddf458c13 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -20,21 +20,26 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (guix scripts offload) - #:use-module (ssh key) - #:use-module (ssh auth) - #:use-module (ssh session) - #:use-module (ssh channel) - #:use-module (ssh popen) - #:use-module (ssh version) + #:autoload (ssh key) (private-key-from-file + public-key-from-file) + #:autoload (ssh auth) (userauth-public-key!) + #:autoload (ssh session) (make-session + connect! get-error + disconnect! session-set!) + #:autoload (ssh version) (zlib-support?) #:use-module (guix config) #:use-module (guix records) - #:use-module (guix ssh) + #:autoload (guix ssh) (authenticate-server* + connect-to-remote-daemon + send-files retrieve-files retrieve-files* + remote-inferior report-guile-error) #:use-module (guix store) - #:use-module (guix inferior) - #:use-module (guix derivations) - #:use-module ((guix serialization) - #:select (nar-error? nar-error-file)) - #:use-module (guix nar) + #:autoload (guix inferior) (inferior-eval close-inferior inferior?) + #:autoload (guix derivations) (read-derivation-from-file + derivation-file-name + build-derivations) + #:autoload (guix serialization) (nar-error? nar-error-file) + #:autoload (guix nar) (restore-file-set) #:use-module ((guix utils) #:select (%current-system)) #:use-module ((guix build syscalls) #:select (fcntl-flock set-thread-name)) @@ -47,12 +52,10 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) - #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 format) - #:use-module (ice-9 binary-ports) #:export (build-machine build-machine? build-machine-name @@ -560,6 +563,15 @@ expired." If TIMEOUT is #f, simply evaluate EXP..." (call-with-timeout timeout drv (lambda () exp ...))) +(define (check-ssh-zlib-support) + "Warn once if libssh lacks zlib support." + ;; We rely on protocol-level compression from libssh to optimize large data + ;; transfers. Warn if it's missing. + (unless (zlib-support?) + (warning (G_ "Guile-SSH lacks zlib support")) + (warning (G_ "data transfers will *not* be compressed!"))) + (set! check-ssh-zlib-support (const #t))) + (define* (process-request wants-local? system drv features #:key print-build-trace? (max-silent-time 3600) @@ -584,6 +596,7 @@ If TIMEOUT is #f, simply evaluate EXP..." (lambda () ;; Offload DRV to MACHINE. (display "# accept\n") + (check-ssh-zlib-support) (let ((drv (read-derivation-from-file drv)) (inputs (string-tokenize (read-line))) (outputs (string-tokenize (read-line)))) @@ -783,12 +796,6 @@ machine." (and=> (passwd:dir (getpw (getuid))) (cut setenv "HOME" <>)) - ;; We rely on protocol-level compression from libssh to optimize large data - ;; transfers. Warn if it's missing. - (unless (zlib-support?) - (warning (G_ "Guile-SSH lacks zlib support")) - (warning (G_ "data transfers will *not* be compressed!"))) - (match args ((system max-silent-time print-build-trace? build-timeout) (let ((max-silent-time (string->number max-silent-time)) |