5 ms·
iceoryx2 uses shared memory and is implemented in rust if anyone wants something off the shelf
by bfrog 2y ago
iceoryx2 uses shared memory and is implemented in rust if anyone wants something off the shelf
- Sytten 2y agoIt looks nice but the lack of async is sadly a non starter for a lot of us.
- apatheticonion 2y agoWith this sort of thing you'd typically wrap the underlying IPC channel in a system thread and redirect messages to/from it within the local process via an async channel. The dedicated system thread for the channel means the local process will never block on the incoming IPC events and the redirected messages will be buffered/enqueded as determined by the async runtime. For reference, I wrote a utility that wraps an IPC library and exposes an async and sync API: https://github.com/alshdavid/ipc-channel-adapter https://github.com/alshdavid/ipc-channel-adapter
- mutatio 2y agoIs shared memory access naturally async like IO/io_uring? If not, asking for async is misplaced and any implementation would be synonymous with wrapping sync calls in `async fn` wrappers.
- dwattttt 2y agoI think it's as naturally async as anything else here actually. If you're calling a function via IPC over shared memory, you're sending a message, signalling it's there to the other process, and waiting for a response message with the result. The only thing needed to turn this async is to change the "get result over IPC" function from "block until result is available" to "check if result is available, return TRY_AGAIN if it's not"
- tialaramex 2y agoIn practice it's not desirable to go without an explicit wake feature, we need some way to know that now it's likely to succeed. The mechanism needn't be 100% reliable but "Always try again" is essentially exactly as useless as blocking.
- bfrog 2y agoThe signaling in this case is typically a shared atomic though not some OS primitive that a process can wake/epoll/etc on?
- loeg 2y agoI believe you could do something with e.g. Linux futexes to support this kind of thing. But in general, polling at the receiver is going to be lower latency / higher throughput.
- elfenpiff 2y agoIn iceoryx2, we use something that we call event concept, which can either use unix-domain sockets so that you have something to select/wake/epoll on or a variant where we use a semaphore stored in shared memory. See: https://github.com/eclipse-iceoryx/iceoryx2/tree/main/iceoryx2-cal/src/event https://github.com/eclipse-iceoryx/iceoryx2/tree/main/iceory... The unix-domain socket has the advantage that you can combine it with external non-iceoryx events, but you pay with a small performance hit. The semaphore event is usually faster. As a user, you can configure your IPC service architecture and use the mechanism that suits you best (but I have to admit that we have not yet documented this in detail). For the zero_copy service variants, it is done here: https://github.com/eclipse-iceoryx/iceoryx2/blob/main/iceoryx2/src/service/zero_copy.rs https://github.com/eclipse-iceoryx/iceoryx2/blob/main/iceory....
- bfrog 2y agoWhat... its shared memory? What is asynchronous about touching a few atomic vars and shared memory (shared pages) exactly? You could absolutely poll on this sort of thing in a non blocking manner, but there is not OS primitive here to trigger a Waker
- gpderetta 2y agobuild an Event Count on top of eventfd and you can get fast pathed blocking behavior on your shared memory queue that it is also async awaitable on top of your event loop of choice.
- elfenpiff 2y agoIf you want to use push notifications to wake up processes, iceoryx2 has the event messaging pattern where a listener waits for incoming events, and a notifier in another process can send specific events to all waiting listeners. See this example: https://github.com/eclipse-iceoryx/iceoryx2/tree/main/examples/rust/event https://github.com/eclipse-iceoryx/iceoryx2/tree/main/exampl...
- renewiltord 2y agoThank you. Good tip.