views:

494

answers:

2

I have a Java-program which communicates with a C++ program using a socket on localhost. Can I expect to gain any performance (either latency, bandwidth, or both) by moving to use a native OS pipe? I'm primarily interested in Windows at the moment, but any insight related to Unix/Linux/OSX is welcome as well.

EDIT: Clarification: both programs run on the same host, currently communicating via a socket, i.e. by making a TCP/IP connection to localhost:. My question was what are the potential performance benefits of switching to using (local) named pipes (Windows), or their Unix equivalent (AF_UNIX domain socket?).

A: 

The first google hit turned up this, which clocked NT4 and XP and found named pipes (that's what you meant, right?) to be faster on Windows.

Ken
I'm confused. The numbers on the page seem to indicate that named pipes are **slower** compared to socket, but maybe I'm reading the numbers wrong.
JesperE
+3  A: 

Ken is right. Named pipes are definitely faster on Windows. On UNIX & Linux, you'd want a UDS or local pipe. Same thing, different name.

Anything other than sockets will be faster for local communication. This includes memory mapped files, local pipes, shared memory, COM, etc.

Pestilence
I'm pretty sure a Unix Domain Socket is different from a named pipe (which do exist on Linux and probably every modern UNIX).
Ken
Oh, just realized you might have meant that either is acceptable, and only "local pipe" is a synonym for "named pipe". I've never heard that (this page is now #3 on google for "linux local pipe"!).
Ken
Yeah, I wasn't very clear. I steered clear of mentioning Apple's named "socket," but still managed to make it confusing. :)
Pestilence
Thanks. You don't happen to have (or know) or any benchmarks?
JesperE
BTW: what about latency vs. bandwidth. The communication pattern is usually lots of small messages sent back and forth, so low latency is probably more important than high bandwidth.
JesperE
Pestilence
That sounds good.
JesperE
By bandwidth I think you mean throughput.
Leeks and Leaks
@leeks-and-leaks Correct. I might was probably inebriated when I typed this out
Pestilence