[Top][All Lists]

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

Re: Unbuffered socket I/O

From: Ludovic Courtès
Subject: Re: Unbuffered socket I/O
Date: Tue, 27 Feb 2007 10:11:20 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)


Neil Jerram <address@hidden> writes:

> I have no technical objection to your patch, but I'm afraid you must
> be missing something, or else there is something special about the
> environment that you were measuring in.  I have played with a few
> TCP-based Guile applications (including the Emacs debugging interface)
> and not noticed any obvious performance problem.

I tried the attached script, both with and without the patch.  Here, it
says "time: 7" with the patch and "time: 2645" without.

Now, it seems that I was observing an even higher difference because the
Guile server script was running under `strace'...  :-)


(use-modules (srfi srfi-4))

(define %port 7778)
(define %size 5000000)

(define (time thunk)
  (let ((start (get-internal-run-time)))
    (let ((end (get-internal-run-time)))
      (format #t "time: ~a~%" (- end start)))))

(if (= 0 (primitive-fork))

    (let ((s (socket PF_INET SOCK_STREAM 0)))
      (bind s AF_INET INADDR_LOOPBACK %port)
      (listen s 1024)

      (format #t "accepting connections...~%")
      (let* ((accepted (accept s))
             (port (car accepted))
             (vec  (make-u8vector %size)))
         (lambda ()
           (uniform-vector-read! vec port)))
        (close-port port)))

    (let ((s (socket PF_INET SOCK_STREAM 0))
          (vec (make-u8vector %size)))
      (format #t "client~%")
      (sleep 1)
      (connect s AF_INET INADDR_LOOPBACK %port)

      (format #t "writing...~%")
      (uniform-vector-write vec s)
      (format #t "done.~%")
      (close-port s)))

reply via email to

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