Re: Unix sockets via TCP on localhost: is TCP slower?

From: Chris Friesen
Date: Thu Nov 13 2008 - 18:04:49 EST


Olaf van der Spek wrote:
On Thu, Nov 13, 2008 at 12:24 PM, Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
Em Thu, Nov 13, 2008 at 12:20:44AM +0100, Olaf van der Spek escreveu:
Hi,

Quite often in discussions, I see people claiming Unix sockets are
faster then TCP sockets on a connection that stays inside localhost.
Let's say from app A to app B.
Is this indeed the case and if so, how much and why?
My assumption is that the kernel can optimize the 'connection' and let
any performance differences disappear.
How much? Please measure.

Lmbench shows local tcp as noticeably slower than unix sockets on a Mac G5 running 2.6.27.


*Local* Communication latencies in microseconds - smaller is better
---------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------- ----- ----- ---- ----- ----- ----- ----- ----
localhost 2.6.27 2.270 10.5 12.6 19.9 31.5 22.7 35.5 68.




*Local* Communication bandwidths in MB/s - bigger is better
-----------------------------------------------------------------------
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
--------- ------- ---- ---- ---- ------ ------ ------ ------ ---- -----
localhost 2.6.27 1368 1564 334. 1111.8 2068.8 930.3 947.0 2072 1269.




Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/