34.1.5 Zero Copy Transfer Over Shared Memory

For communication within the same node using the built-in shared memory transport, by default Connext copies a sample four times (see Figure 34.3: Number of Copies Out-of-the-Box). FlatData language binding reduces the number of copies to two (see Figure 34.4: Number of Copies Using FlatData Language Binding): the copy of the sample into the shared memory segment in the publishing application and the copy to reassemble the sample in the subscribing application. Two copies, however, may still be too many depending on the sample size and system requirements.

Zero Copy transfer over shared memory, provided as a separate library called nddsmetp, allows reducing the number of copies to zero for communications within the same host. The nddsmetp library can be linked with Connext C or C++ libraries. This feature accomplishes zero copies by using the shared memory (SHMEM) built-in transport to send 16-byte references to samples within a SHMEM segment owned by the DataWriter, instead of using the SHMEM built-in transport to send the serialized sample content by making a copy. See Figure 34.5: Zero Copy Transfer Over Shared Memory.

With Zero Copy transfer over shared memory, there is no need for the DataWriter to serialize a sample, and there is no need for the DataReader to deserialize an incoming sample since the sample is accessed directly on the SHMEM segment created by the DataWriter.

Figure 34.5: Zero Copy Transfer Over Shared Memory

This feature offers the following benefits:

  • Number of copies is reduced from four to zero (see SHMEM in Figure 34.3: Number of Copies Out-of-the-Box). Instead of transferring the entire sample by making multiple copies, only the location in shared memory is distributed to DataReaders (see Figure 34.5: Zero Copy Transfer Over Shared Memory).
  • Because of this reduced data copying, memory consumption and CPU load are also reduced.
  • Latency is independent of the size of the sample.
  • Fragmentation is not required when using Zero Copy transfer over shared memory because the DataWriter exchanges SHMEM references (only 16-bytes) with DataReaders and not the full sample.
  • Data can still be sent off-board, simplifying application deployment and configuration. When the data is sent off-board, the middleware is still making the same copies described in Figure 34.3: Number of Copies Out-of-the-Box. To reduce the number of copies for sending off-board, use FlatData language binding in conjunction with Zero Copy transfer over shared memory.

Note: A Zero Copy DataWriter is defined as any DataWriter with the ability to send a sample reference. You can have a DataWriter that does both: sends sample references to Zero Copy DataReaders, and sends serialized samples to non-Zero Copy DataReaders. In this case, the DataWriter is still considered a Zero Copy DataWriter in this documentation.