Welcome to the third episode of the "Cyclone DDS Unleashed" webinar series.
Martijn Reicher, who is our Senior Software Developer, will host this webinar and he’ll talk about how shared memory exchange works, what you need to use, data model choices and at the end, he’ll do a live demo and answer your questions afterwards.
If you have any questions and you want to reach out, you can send us an email at contact@zettascale.tech or join our Discord channel: https://discord.gg/6GwdBxntxt
You can read more about Cyclone DDS on our website: https://www.zettascale.tech/product/cyclone
Stay up to date with the latest news:
Twitter: https://twitter.com/zettascaletech
LinkedIn: https://www.linkedin.com/company/zettascaletech/
Website: https://www.zettascale.tech/
Newsletter: http://eepurl.com/igPw31
3. DDS concepts
• Shared Dataspace
• Data-centric
• Publish-Subscribe model
• Only receive data of interest
• Dynamic discovery
• No input from user necessary
5. Normal Data Flow
• Data is Copied at (fat arrow):
• Modification
• Handing over to DDS
• Serialization
• Write to Network
• Read from Network (times number of instances)
• Deserialization
• Access
6. • Assign a pool of memory "shared" by instances of CycloneDDS
• Have writers "take" a block of memory from the pool
• Notify readers of written blocks
• Readers present data to user
• User signals when block is no longer in use
• Block is returned to the pool
System Level
7. Shared memory Flow
• Data is copied at (fat arrow):
• Modification
• Serialization (dependent on data
model)
• Deserialization (dependent on data
model)
• Access
8. • Skip network stack
• No copying into/out of buffers from network
• Lower latency
• If samples in same layout & no indirections:
• No serialization necessary
• Negligible overhead from multiple readers
Performance gains
10. Indicators for SHM Exchange
• Large Volumes of Intra-Node Data Traffic:
• Frequency (samples/sec)
• Size (bytes/sample)
• Number of Readers
• Low History depth:
• Required size of memory pool scales with history
• Simple Data Structures:
• No indirections (sequences/strings/etc.):
• No serialization necessary
• Same data layout (no mixing of programming languages)
11. Typical Use cases
• LIDAR pointclouds / Hi-res Camera Images
• 10MB, 30 times per second
• Usually unachievable using naïve copy implementations
• Dynamic scalable pipeline architecture
• Samples being passed through different types of analyses
• No copying, so no scaling with data throughput/number of steps
• Analysis is done only once and distributed without copying
• Dynamic addition of producers/consumers
• Different security levels for processes
13. Software
• Install iceoryx (https://github.com/eclipse-iceoryx/iceoryx)
• iceoryx is a sister project of CycloneDDS and the current Shared Memory
service for CycloneDDS
• Add to Path
• Install CycloneDDS (https://github.com/eclipse-cyclonedds/cyclonedds)
• Compile with shared memory support: -DENABLE_SHM=On
• Add to Path
• Compile Program
• Start iceoryx service iox-roudi
14. Configuring CycloneDDS
• CycloneDDS configuration files:
• Set config Domain(id) >
SharedMemory > Enable to true
• Optionally set LogLevel to the
desired level for shared memory
• Environment variable:
CYCLONEDDS_URI
<CycloneDDS>
<Domain id="any">
<SharedMemory>
<Enable>true</Enable>
<LogLevel>info</LogLevel>
</SharedMemory>
</Domain>
</CycloneDDS>
15. Configuring iceoryx
• iceoryx configuration files:
• Determine memory pool layout
• Size of mempool segments:
• 64 bytes larger than maximum
sample size
• Number depends on use case
• iox-roudi –c config_file.toml
[general]
version = 1
[[segment]]
[[segment.mempool]]
size = 1048640
count = 500
16. Data Model
• You can optimize your Data Model for Shared Memory Exchange
• Shared Memory Exchange works best when there are no indirections
• Indirections cause CycloneDDS to serialize the data
• Indirections are:
• Strings, Sequences: replace with fixed size arrays of chars
• Other Containers: Optionals, Externals: Do not use
• Only final types
17. Loan mechanism
• Using Loaned Samples increases performance:
• Loaned samples are pre-assigned by the reader/writer handling the
samples
• Removes a copy step in transferring data
• Writers: request a loan: dds_loan_sample
• Sample is returned on call to dds_write
• Implementation in progress for Readers
18. Limitations
• Inter-node communication
• Adding non-local nodes removes many performance gains
• Simple data structures
• Cannot use indirections for best performance
• Memory pool
• History is limited by memory available
• Reliance on iceoryx
• Unavailable on certain OSes