chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] TCP speedup


From: Jim Ursetto
Subject: [Chicken-hackers] TCP speedup
Date: Tue, 26 Feb 2008 04:30:05 -0600

Hi core hackers,

Please consider this TCP patch, which speeds up the output port a LOT; the
larger the write, the bigger the speedup.

Currently, write chunking (in 8192 byte doses) is done with ##sys#substring.
This creates a huge copy overhead and large amounts of garbage.  This patch
adds an offset to ##net#send so no copying is required.

I did some tests with spiffy to demonstrate the order of speedup to
expect.  These tests were done by sending out a string with write-string
in http:add-resource.

                 Without patch   With patch      sendfile egg (mmap)
;; 512000 bytes  20-37.5 r/s       630 r/s           86 r/s
;; 128000 bytes  175 r/s          1250 r/s              N/A
;; 35000 bytes   1000-1500 r/s    2000-2300 r/s    1450 r/s
;;  1450 bytes   2000 r/s         2000-2500 r/s    1200-1500 r/s

Amusingly, it is now faster than the sendfile egg on OS X.

These are some benchmarks I did to convince myself this was worth
implementing in the first place.  They test the overhead of
substring in this use case.  Notice the massive number of GCs.

;; (time (ntimes 1000000 test-substr (make-string 8191)))
   0.118 s   0 major GCs
;; (time (ntimes 1000000 test-offset (make-string 8191)))
   0.121 s   0 major GCs

;; (time (ntimes 1000000 test-substr (make-string 35000)))
   33.328 s  17149 major GCs
;; (time (ntimes 1000000 test-offset (make-string 35000)))
   0.282 s   0 major GCs

;; (time (ntimes 1000 test-substr (make-string 512000)))
   22.745 s  9501 major GCs
;; (time (ntimes 1000 test-offset (make-string 512000)))
   0.003 s      1 major GCs

Attachment: tcp-offset.diff
Description: Binary data


reply via email to

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