Inter process communication used in capnp

243 views
Skip to first unread message

Omega Ishendra

unread,
Jan 21, 2019, 2:23:39 AM1/21/19
to Cap'n Proto
Hi all,

I know that communication between two processes can be done mainly using two methods.
  1. Shared Memory
  2. Message passing

my initial idea about capnp is, it is using "Message Passing".

Is my idea correct?
Can we do Inter-Process-Communication using shared memory in capnp?
which is the faster?

Thanks,

Justin Cormack

unread,
Jan 23, 2019, 4:06:03 AM1/23/19
to Omega Ishendra, Cap'n Proto
You can do IPC. I did some work on a Go memfd implementation a while
back https://github.com/justincormack/go-memfd/tree/master/memproto

Whether it is faster depends a lot on circumstances, such as how large
your messages are, and how efficient your shared memory implementation
is. If you are performance constrained, you might want to benchmark
it, but otherwise something else is likely a constraint.
> --
> You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
> Visit this group at https://groups.google.com/group/capnproto.

Kenton Varda

unread,
Jan 23, 2019, 4:19:13 PM1/23/19
to Omega Ishendra, Cap'n Proto
I think the way I'd do shared memory Cap'n Proto would be to have a large shared memory space mapped upfront, allocate/write each message within the space, and then signal to the other process "you can find a new message located at position X", "I am done with the message located at position Y", etc.

This has always been something I intended to implement, but so far it hasn't come up as a priority. Sending messages over a unix socket is easy and works well, so I'd recommend trying that first, and considering shared memory transport as a possible optimization later on.

-Kenton

Taylor Dawson

unread,
Feb 5, 2021, 5:39:01 PM2/5/21
to Cap'n Proto
@Ken how much latency can you shave off with shared memory vs unix sockets? Cc @Justin if you have any comparisons? 

Thanks!

Kenton Varda

unread,
Feb 5, 2021, 5:46:34 PM2/5/21
to Taylor Dawson, Cap'n Proto
Sorry, I really don't know since I haven't tried it yet. There's a lot of potential to eliminate copies and syscalls here, but how much impact that really makes would of course depend on what else your system is doing.

(Note that I go by "Kenton", not "Ken"...)

-Kenton

Taylor Dawson

unread,
Feb 5, 2021, 5:53:01 PM2/5/21
to Cap'n Proto
My apologies! I saw your email "ken..." and wrote without thinking 😅

Right I see. I may try it out and see

Thanks!
Reply all
Reply to author
Forward
0 new messages