我有一个 Java 程序,它使用本地主机上的套接字与 C++ 程序进行通信。通过转而使用本机操作系统管道,我是否可以期望获得任何性能(延迟、带宽或两者兼而有之)?目前我主要对 Windows 感兴趣,但也欢迎任何与 Unix/Linux/OSX 相关的见解。
编辑:澄清:两个程序在同一主机上运行,当前通过套接字进行通信,即通过与 localhost: 建立 TCP/IP 连接。我的问题是切换到使用(本地)命名管道(Windows)或其 Unix 等效项(AF_UNIX 域套接字?)的潜在性能优势是什么。
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?).
发布评论
评论(3)
肯是对的。命名管道在 Windows 上肯定更快。在 UNIX 和 Linux 上Linux,您需要 UDS 或本地管道。一样的东西,不同的名字。
对于本地通信来说,除了套接字之外的任何东西都会更快。这包括内存映射文件、本地管道、共享内存、COM 等。
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.
第一个谷歌点击出现了这个,它的时钟为NT4和XP,发现命名管道(这就是你的意思,对吧?)在 Windows 上更快。
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.
对于本地进程来说,通信管道肯定比套接字更快。这是基准或缓存此处。
我认为即使套接字很灵活,但它也会导致糟糕的代码设计。在使用管道时,它强制您设计项目的架构,例如哪个进程应该是父进程,哪个进程应该是子进程,以及它们如何合作(这将决定管道的建立方式),并为进程分配不同的功能。这样您的项目设计将具有层次结构并且易于维护。
https://web.archive.org/web/20160401124744/https://sites.google.com/site/rikkus/sysv-ipc-vs-unix-pipes-vs-unix-sockets< /a>
For local processes communication pipes are definitely faster than sockets. Here is a benchmark or cached here.
I think even though socket is flexible but it can also lead to bad code design. While using pipe it enforces you to design the architecture of your project like which process should be the parent which should be the children and how they cooperate(this will determine how pipes are established) and assign different functionality to processes. Your project design this way will have hierarchical structure and easy to maintain.
https://web.archive.org/web/20160401124744/https://sites.google.com/site/rikkus/sysv-ipc-vs-unix-pipes-vs-unix-sockets