Replies: 3 comments 1 reply
Btw. All our C++ containers are memory layout compatible with their rust counterparts, so you can use them for inter-process communication between Rust and C++ as well. This is demonstrated in the "cross language communication container" and "cross language communication complex types" examples, see the overview here: https://github.com/eclipse-iceoryx/iceoryx2/tree/main/examples#overview |
|
We are also discussing a more experimental (and perhaps immature) idea internally: Is there a better or more transparent way to transform native STL containers into static/shared-memory-safe containers? For example, instead of requiring application developers to manually rewrite interfaces from
The motivation is mainly to reduce migration cost for large existing C++ codebases while still preserving deterministic behavior and as much zero-copy capability as possible. We fully understand that native STL containers fundamentally depend on pointers and heap allocation, which makes true cross-process zero-copy semantics difficult or even impossible in the general case. So we are not expecting a “magic zero-copy std::vector”. Instead, what we are wondering is whether there could be a more ergonomic bridge between:
One possible direction could be:
Another possibility might be:
We would be very interested in hearing your thoughts on whether such a direction could align with the long-term philosophy of iceoryx2, or whether there are fundamental technical or architectural reasons why this approach would not be recommended. Thanks again for the excellent explanations and examples. |
|
Hey @ShanTaoDD thank you for your ideas.
Yes, there are. If you are able to use polymorphic allocator containers like the C++
With this adaptation, we could use
This makes absolutely sense! Those conversation operators should be easy to integrate. Since we are a safety-critical project we are unable to use exceptions when a static container conversion constructor fails since its capacity is too small. The solution is, that we use static construction methods that return an expected. Would such an API be fine for you? std::vector<int> my_data;
auto converted_data = iox2::StaticVector<int, 123>::from_vector(my_data)
.expect("error handling done here");
This I didn't get, what do you mean by that?
We could add those to So I would explore other options first, but I agree that the wrappers make sense for less critical systems and that we should provide this in the long run in iceoryx2 as well.
We see iceoryx2 as a toolbox that can be configured to support any use-case you have. Instead of forcing the user to use a specific set of things, containers, or libraries, you can mix and match as you want. So your proposed solutions align very well with the long-term philosophy of iceoryx2! I would recommend pursuing an allocator-based shared-memory STL approach. This feature would solve many other problems besides yours. Currently, users always have to make worst-case estimations for their payload, due to the static nature, and this is often harder than it looks. Our working mode is that we work on those bigger features when we have secured the funding for them. Either by a paying customer or some public funding. This ensures that we can continue the open-source work and maintenance of iceoryx2. So if you like to accelerate the development of this feature, you could get in contact with us: info@ekxide.io |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I’m currently evaluating iceoryx2 for zero-copy IPC in a C++ system.
One practical challenge is how to efficiently transmit variable-length
data structures like std::vector, std::string, or nested containers.
I understand that STL containers cannot be directly used due to:
Currently, the recommended approach seems to be:
However, from a usability and API design perspective, this introduces
friction compared to standard C++ usage.
Questions:
Are there plans to provide a zero-copy-friendly container abstraction
for C++ (e.g., something like a relocatable vector or span-based container)?
Is there a recommended pattern for building higher-level abstractions
on top of shared memory (e.g., for nested containers)?
How does the team envision bridging the gap between Rust slice-based APIs
and C++ STL-based APIs?
Would a "ShmVector" abstraction (offset-based, contiguous storage)
be aligned with the design philosophy of iceoryx2?
Thanks!
All reactions