0

I understand, if shared memory is used correctly it can be faster than any other kind of IPC. My question is a bit more specific: If I transfer many small packets, eg 100 bytes, from different programs to one main program, what kind of speed difference can I expect?

JoeFrom
  • 11
  • 3
  • Why don't you test it? It sounds like a very straightforward test... – Dietrich Epp Feb 05 '14 at 05:56
  • 1
    A related question [here](http://stackoverflow.com/questions/2101671/unix-domain-sockets-vs-shared-memory-mapped-file) from a more lenient time. – Brett Hale Feb 05 '14 at 06:12
  • "Speed" Could mean bytes per sec, messages per sec, latency or Even CPU load... And all are totally dependant on your code. So test it if you want to know. – hyde Feb 05 '14 at 06:14

1 Answers1

3

The benefit from using shared memory will not be so much, because you will end up with using conditional variables on the shared memory (cf. pthread_condattr_setpshared; it will be a substantial coding work, by the way.) Then your logic is governed by the OS scheduler, and it's not very different from using localhost TCP connection which has a different and fast implementation than standard TCP on most OS.

If it's OK to entirely rely on a spinlock on the shared mem, then you will indeed realize substantial speed up like x3 fold.

nodakai
  • 7,773
  • 3
  • 30
  • 60