[Top][All Lists]

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

bug#15368: HTTP client is slow [2.0.9]

From: Ludovic Courtès
Subject: bug#15368: HTTP client is slow [2.0.9]
Date: Fri, 13 Sep 2013 15:41:27 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

I just noticed that our HTTP client is very slow.  Consider this:

--8<---------------cut here---------------start------------->8---
(use-modules (web client)
             (rnrs io ports)
             (rnrs bytevectors)
             (srfi srfi-11)
             (ice-9 format))

(define %uri

(with-fluids ((%default-port-encoding #f))
  (let*-values (((start)
                 (let ((s (open-socket-for-uri %uri)))
                   (setvbuf s _IONBF)
                ((r h)
                 (http-get %uri
                           #:port p
                           #:streaming? #t
                           #:decode-body? #f))
                ((d len)
                 (let ((b (get-bytevector-all h)))
                   (values b (bytevector-length b)))
                 ;; (let ((b (make-bytevector (* 5 (expt 2 20)))))
                 ;;   (values b
                 ;;           (get-bytevector-n! h b 0 (bytevector-length b))))
                 (let ((duration (- (car end) (car start))))
                   (/ (/ len 1024.) duration 1.0))))
    (format #t "~5,1f KiB/s (total: ~5,1f KiB)~%"
            throughput (/ len 1024.))))
--8<---------------cut here---------------end--------------->8---

Here I get a throughput of ~60 KiB/s, vs. ~400 KiB/s for wget and curl.

Looking at the strace output reveals no real difference: they all make
one syscall for each chunk of 1410 bytes.

‘time’ reports that Guile spends 0.2 s. in user and 0.8 s. in system,
both of which are an order of magnitude higher than wget/curl.

Bypassing the custom binary input ports from http.scm and response.scm
doesn’t make any big difference.  Forcing the zero-copy path in
‘scm_c_read’ doesn’t help much either.



reply via email to

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