delphij's Chaos

选择chaos这个词是因为~~实在很难找到一个更合适的词来形容这儿了……

07 Oct 2006

Andre's optimization to the FreeBSD socket send path

For those who does not track FreeBSD-CURRENT -current@, Andre Opperamann (andre@) has just posted a new progress for his TCP/IP optimization:

This is a continuation of the previous postings with similiar titles. New is a specific soreceive_stream() function for stream protocols (primarily TCP)
that does only one socket buffer lock per socket read instead of one per data mbuf
copied to userland. When doing netperf tests with WITNESS (full lock tracking and
validation enabled) the receive performance increases from ~360Mbit/s to ~520Mbit/s.
Without WITNESS I could not measure any statistically significant improvement on a
otherwise unloaded machine. The reason is two-fold: 1) per packet we do a wakeup
and readv() is pretty much as many times as packets come it, thus the general over-
head dominates; 2) the packet input path has a pretty high overhead too. On heavily
loaded machines which do a lot of high speed receives a performance increase should
be measureable.

This patch rolls the improved sendfile(2), sosend_*() and soreceive_stream()
functions. In general the send path is improved by between 2.8 and 5.7 times.

The patch is available here:
http://people.freebsd.org/~andre/sendfile+sosend+soreceive-20061006.diff

Any testing and heavy (code) beating and reviews welcome.