From 50dc48922cc88faec10e8759f58f231bb08f0684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 8 Nov 2013 22:47:02 +0100 Subject: [PATCH] substitute-binary: Increase lookup concurrency to reduce latency. * guix/scripts/substitute-binary.scm (%lookup-threads): New variable. (guix-substitute-binary): Use 'n-par-map' instead of 'par-map' for batch 'lookup-narinfo' calls. --- guix/scripts/substitute-binary.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm index 1afc93bbc9..44699cfca9 100755 --- a/guix/scripts/substitute-binary.scm +++ b/guix/scripts/substitute-binary.scm @@ -290,6 +290,12 @@ (define (obsolete? date now ttl) (time>? (subtract-duration now (make-time time-duration 0 ttl)) (make-time time-monotonic 0 date))) +(define %lookup-threads + ;; Number of threads spawned to perform lookup operations. This means we + ;; can have this many simultaneous HTTP GET requests to the server, which + ;; limits the impact of connection latency. + 20) + (define (lookup-narinfo cache path) "Check locally if we have valid info about PATH, otherwise go to CACHE and check what it has." @@ -489,8 +495,9 @@ (define (guix-substitute-binary . args) ;; Return the subset of PATHS available in CACHE. (let ((substitutable (if cache - (par-map (cut lookup-narinfo cache <>) - paths) + (n-par-map %lookup-threads + (cut lookup-narinfo cache <>) + paths) '()))) (for-each (lambda (narinfo) (when narinfo @@ -501,8 +508,9 @@ (define (guix-substitute-binary . args) ;; Reply info about PATHS if it's in CACHE. (let ((substitutable (if cache - (par-map (cut lookup-narinfo cache <>) - paths) + (n-par-map %lookup-threads + (cut lookup-narinfo cache <>) + paths) '()))) (for-each (lambda (narinfo) (format #t "~a\n~a\n~a\n"