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.
This commit is contained in:
Ludovic Courtès 2013-11-08 22:47:02 +01:00
parent 6a9957545c
commit 50dc48922c
1 changed files with 12 additions and 4 deletions

View File

@ -290,6 +290,12 @@ reading PORT."
(time>? (subtract-duration now (make-time time-duration 0 ttl)) (time>? (subtract-duration now (make-time time-duration 0 ttl))
(make-time time-monotonic 0 date))) (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) (define (lookup-narinfo cache path)
"Check locally if we have valid info about PATH, otherwise go to CACHE and "Check locally if we have valid info about PATH, otherwise go to CACHE and
check what it has." check what it has."
@ -489,8 +495,9 @@ Internal tool to substitute a pre-built binary to a local build.\n"))
;; Return the subset of PATHS available in CACHE. ;; Return the subset of PATHS available in CACHE.
(let ((substitutable (let ((substitutable
(if cache (if cache
(par-map (cut lookup-narinfo cache <>) (n-par-map %lookup-threads
paths) (cut lookup-narinfo cache <>)
paths)
'()))) '())))
(for-each (lambda (narinfo) (for-each (lambda (narinfo)
(when narinfo (when narinfo
@ -501,8 +508,9 @@ Internal tool to substitute a pre-built binary to a local build.\n"))
;; Reply info about PATHS if it's in CACHE. ;; Reply info about PATHS if it's in CACHE.
(let ((substitutable (let ((substitutable
(if cache (if cache
(par-map (cut lookup-narinfo cache <>) (n-par-map %lookup-threads
paths) (cut lookup-narinfo cache <>)
paths)
'()))) '())))
(for-each (lambda (narinfo) (for-each (lambda (narinfo)
(format #t "~a\n~a\n~a\n" (format #t "~a\n~a\n~a\n"