ipc-bench
ipc-bench copied to clipboard
Why mq is faster than shm?
Hello~ I tried running ipc-bench on my desktop to check IPC performance. Below is a comparison of the results of shm and mq. Comparing the total time or average time, mq is faster than shm. Is there something I haven't tested well?
$./shm -s 1000000 -c 128 ============ RESULTS ================ Message size: 1000000 Message count: 128 Total duration: 52.356 ms Average duration: 408.928 us Minimum duration: 305.664 us Maximum duration: 4580.096 us Standard deviation: 375.195 us Message rate: 2444 msg/s
$./mq -s 1000000 -c 128 ============ RESULTS ================ Message size: 2048 Message count: 128 Total duration: 2.603 ms Average duration: 20.246 us Minimum duration: 18.688 us Maximum duration: 82.432 us Standard deviation: 5.764 us Message rate: 49178 msg/s
Thanks for trying out the benchmark. It appears that you are using to very different message sizes:
Message size: 1000000
vs
Message size: 2048
.
That should explain the difference.
Best, Alex
Hello, for me mmap displays 147 msg/s
. Although I think there must be a problem, I tried restarting the server but that didn't help. The command return immediately and takes a long time to display a result, sometime no results. Also, the command shm-sync
return nothing, the process is not even started according to the `htop command. Thanks in advance for your help !
Hi @RealAlphabet ,
Sorry for the late reply, I was busy with other projects, but I found some time now and I am revisiting some of the issues and trying to update the code a little bit.
-
I actually pushed one fix that should take care of the issue where the command returns immediately: The command
./build/source/shm/shm
used to simply spawn (fork
&exec
) two child processes (server and client) and quit. After that children carry out their work and report the results. Hence you run the command, it returns immediately and the results appear after a while. I now fixed this by making the root process always wait for its children. -
Regarding the message rate of only
147 msg/s
. Depending on the message size this is very possible. If you are transmitting 30MB messages this means you are using around 9GB/s bandwidth. Depending on the machine this is very reasonable. -
shm-sync
is broken on my end too. I might have a look at it some time.
Best, Alex