Shared memory vs UDP

2 posts / 0 new
Last post
Last seen: 1 year 4 months ago
Joined: 01/26/2016
Posts: 11
Shared memory vs UDP


I have a question concerning the transport via UDP and shared memory. Are there any reason to use one instead of the other? 

The different use cases are:

- send small messages between processes on the same computer (idl = {long myLong; string<64> myString;})

- send large images between processes on the same computer (image contains around 10 000 000 pixels)

We need high performance, especially for images. We are currently using UDP transport, do you think it is a good solution?


Thank you,


jmorales's picture
Last seen: 4 months 3 weeks ago
Joined: 08/28/2013
Posts: 40

Hi Lucie,

I would definitely recomend using shared memory in your scenario.

In most of the cases shared memory is going to perform better, providing you with lower latencies and higher throughputs. In scenarios where you want to send in the same machine from 1 publisher to a few subscribers it should provide the best results. In fact, if you don't change any setting, RTI Connext DDS will automatically choose that transport for communications in the same machine.

Then, just a note for the second scenario you mention:

You intend to send pretty big samples: lets say 10.000.000 pixels x 3 componets x 8 bytes = 240.000.000 = 228 MBytes per sample.

If you choose to use UDPv4, then the message_size_max (more info here) maximum value will be the maximum size of an UDPv4 packet: 64K (default value for message_size_max in 5.2.3). Therefore, RTI Connext DDS will need to use fragmentation to be able to send your sample. If you are using reliable communications, then you will need to use Asynchronous Publishing (more info here). When using Asynchronous Publishing a default Flow Controller is chosen, but usually for fine tunning, you will want to use your own parameters (more info in the documentation and here).

If you choose to use SHMEM, then the message_size_max can be increased to way bigger values, so initially you could even avoid fragmentation, and you will not need to use Asynchronous Publishing. You will also need to tune a few buffers. Read the following solution for some more information: Link.

I hope this info helps, let me know how it goes :D.