Browse Source

download: Enlarge your receive buffer.

* guix/build/download.scm (open-connection-for-uri): Remove call to
  'setsockopt'.
* guix/http-client.scm (open-socket-for-uri)[rmem-max, buffer-size]: New
  variables.  Add call to 'setsockopt'.
gn-latest-20200428
Ludovic Courtès 6 years ago
parent
commit
a68d976b66
2 changed files with 12 additions and 2 deletions
  1. +0
    -2
      guix/build/download.scm
  2. +12
    -0
      guix/http-client.scm

+ 0
- 2
guix/build/download.scm View File

@@ -167,8 +167,6 @@ which is not available during bootstrap."

;; Buffer input and output on this port.
(setvbuf s _IOFBF)
;; Enlarge the receive buffer.
(setsockopt s SOL_SOCKET SO_RCVBUF (* 12 1024))

(if (eq? 'https (uri-scheme uri))
(tls-wrap s)


+ 12
- 0
guix/http-client.scm View File

@@ -162,7 +162,19 @@ closed it will also close PORT, unless the KEEP-ALIVE? is true."
(define* (open-socket-for-uri uri #:key (buffered? #t))
"Return an open port for URI. When BUFFERED? is false, the returned port is
unbuffered."
(define rmem-max
;; The maximum size for a receive buffer on Linux, see socket(7).
"/proc/sys/net/core/rmem_max")

(define buffer-size
(if (file-exists? rmem-max)
(call-with-input-file rmem-max read)
126976)) ; the default for Linux, per 'rmem_default'

(let ((s ((@ (web client) open-socket-for-uri) uri)))
;; Work around <http://bugs.gnu.org/15368> by restoring a decent
;; buffer size.
(setsockopt s SOL_SOCKET SO_RCVBUF buffer-size)
(unless buffered?
(setvbuf s _IONBF))
s))


Loading…
Cancel
Save