All,
Thank you for the good discussion today. I think we've got the right
ideas on how to move forward.
* Ach *
I've set up a public Git repository for Ach and created a rosinstall
file, so hopefully building the library will fairly painless.
Instructions are here:
https://github.com/golems/golems-ros
* IPC for Vision *
For the problem of transmitting large image messages with minimal
copying, here is an idea I had for sending messages to multiple
subscribers using only a single copy. The basic idea is to use
virtual memory to map the message into each process's address space.
Here is one way to do that:
- Publisher:
(1) Call shm_open and mmap to create an arbitrary shared memory file.
(2) Call shm_unlink to unlink the shared memory file in the file
system. Publisher still has it open.
(3) Copy/serialize/generate the message into the mmap'ed shared
memory file.
(4) Send the /FILE DESCRIPTOR/ to all subscribing processes via a
Local-Domain socket or POSIX message queue.
(5) Munmap and close the shared memory file.
- Subscriber:
(1) Receive the file descriptor from publisher.
(2) Mmap the file descriptor.
(3) Operate on data in the shared memory file.
(4) Munmap and close the shared memory file.
- OS Kernel:
- Keeps track of reference counts to the underlying physical memory
for the shared memory file.
- Garbage-collects that physical memory when all processes close the
file.
So the tradeoff is that we pay for these extra system calls in order
to eliminate the extra copies. This is probably a win for
multi-megabyte messages. I'm not sure whether there would be issues
with fragmentation and CPU-cache friendliness, though.
If this sounds like something useful, I think it would be neat to
implement. Of course, we also want Ach integrated as a ROS transport,
and there is a finite amount of time. Any interest in helping with
implementation?
--
Neil Dantam
http://www.cc.gatech.edu/~ndantam3