小编典典
刚刚在我的Corei5 2.8GHz上测试了Java的延迟,仅发送/接收了单字节,仅产生了2个Java进程,而没有为任务集分配特定的CPU内核:
TCP - 25 microseconds
Named pipes - 15 microseconds
现在明确指定核心掩码,例如 taskset 1 java Srv 或 taskset 2 java Cli :
TCP, same cores: 30 microseconds
TCP, explicit different cores: 22 microseconds
Named pipes, same core: 4-5 microseconds !!!!
Named pipes, taskset different cores: 7-8 microseconds !!!!
所以
TCP overhead is visible
scheduling overhead (or core caches?) is also the culprit
同时Thread.sleep(0)(如strace所示,导致执行单个sched_yield()Linux内核调用)需要0.3微秒-
因此,调度到单核的命名管道仍然有很多开销
一些共享内存的度量: 2009年9月14日– Solace
Systems今天宣布,使用共享内存传输,其统一消息平台API可以实现平均延迟小于700纳秒。
http://solacesystems.com/news/fastest-ipc-
messaging/
PS-第二天以内存映射文件的形式尝试了共享内存,如果可以接受繁忙的等待,