News for hackers. Stuff that matters.
Re:Fuchsia IDL Overview by surajrmal on Thursday March 17, 2022 @03:42AM (#30708579)
Sure. In IPC, you can have shared resources such as memory. In RPC, you need to assume all parties may be on separate systems. In IPC, you may be able to make guarantees about message ordering that are more challenging with RPC. For instance, packets may be dropped over a network link and packets may arrive out of order. In IPC, you can express backpressure without the need for packet dropping, and therefore can avoid overhead of things like TCP. With IPC, links are trusted, so you can avoid encrypting messages, but that is not something you can safely assume with RPC. Because of these sorts of things, the cost of sending a message is relatively low (measured in us) compared to RPC (measured in hundreds of us), and so the cost of serialization may be of greater concern as it may start to dominate cost. As a result, you may optimize your serialization format differently. Beyond that, an IPC system may allow for advanced usage of the shared kernel which is not possible across different systems each with a separate kernel.
Re:Fuchsia IDL Overview by spc476 on Thursday March 17, 2022 @03:51AM (#30708629)
QNX makes no distinction between IPC and RPC. In fact, a program won't be able to tell if the other end of a message port was on the same CPU, same computer, or network (well, maybe by timing results). You didn't even need to recompile code to get that either. It just works right out of the box.
Re:Fuchsia IDL Overview by surajrmal on Thursday March 17, 2022 @04:05AM (#30708708)
When you do this, you have to live by the combined constraints of both transports. It's not necessarily wrong, but having different mechanisms which are optimized for the specific constraints of each is also valid.
Re:Fuchsia IDL Overview by ithkuil on Thursday March 17, 2022 @04:12AM (#30708749)
I wonder how many of those constraints actually apply to the IDL and surrounding programming model as opposed to the mere (de)serialization.

Could we have a single IDL that generates two sets of serialization code one optimized for IPC and the other for network transport?

Re:Fuchsia IDL Overview by surajrmal on Thursday March 17, 2022 @12:00PM (#30712596)
I'll give you a more concrete experience. We have protocols designed to take advantage of shared memory to allow dma directly from the hardware to the pages backing the file you end up reading from. There are many layers/processes between my program and the driver which ultimately talks to the hardware, and being able to bypass copies for the data is useful. Now the protocol encodes this expectation of shared memory usage within it. We later built a mechanism to take existing protocols and use them across network boundaries, but were unable to utilize any protocols which relied on shared memory. It may be possible to emulate shared memory across the network boundary, but it's hard to do so performantly in all cases. So rather than modify the existing protocol to avoid shared memory, negatively affecting existing use cases, we opted to create a second protocol which was optimized for network use cases.

There are more of these sorts of examples I could enumerate if you find it worthwhile.

Re:Fuchsia IDL Overview by pjmlp on Thursday March 17, 2022 @05:39AM (#30709274)
COM, .NET Remote and RMI do it.
Re:Fuchsia IDL Overview by Kinrany on Thursday March 17, 2022 @11:31AM (#30712226)
It should be possible to encode those constraints as part of the language. For example, the distinction between sync and async calls can be represented by having a Future type and wrapping the return type in it.
Re:Fuchsia IDL Overview by znwu on Friday March 18, 2022 @04:19AM (#30719750)
Sync and async are all about cooperatively yielding control flow. However, in many cases, you may want to yield control on IPC, or to hold onto control on RPC. Yielding control depends on the sender logic. IPC/RPC depends on receiver characteristics. They are very orthogonal concepts.
Re:Fuchsia IDL Overview by sriram_sun on Thursday March 17, 2022 @01:22PM (#30713587)
QNX is able to do this because QNX doesn't understand shared memory. Everything is a message/channel.
Re:Fuchsia IDL Overview by guiriduro on Thursday March 17, 2022 @05:55AM (#30709357)
I'm struggling to see why you'd want a specialised explicit IDL for IPC-only, as against it being an implementation detail using same address-space optimisation if services are co-located. E.g. cf OmniORB (CORBA) [1]

While you can have tightly-coupled, highly interactive IPC that would be pathological over RPC, where DSL/IDL and protocol semantics rightly focus on more loosly-coupled service interfaces with network error recovery, I question whether it is desirable even in the IPC case. Intra-service IPC within a single runtime can be as chatty as needed without becoming an Inter-service call (and potentially RPC in other architectures), so does Fuschia answer to an actual need - is there actually a valid use case for tight-coupled highly interactive local inter-service IPC that isn't better architected assuming RPC? Is the benefit of assumed IPC between co-located client/servers an actual problem that 'colocation optimised' RPC doesn't already solve well enough?

[1] https://www.omniorb-support.com/pipermail/omniorb-list/2006-...

Re:Fuchsia IDL Overview by kllrnohj on Thursday March 17, 2022 @07:17AM (#30709835)
RPCs aren't just slower for IPC, they are also missing very useful features. Like it's not possible to send an open file descriptor across RPC, but it's very possible (and very useful) to do the same over IPC. It's how something like an "open file dialog" can work without needing the app process to have full access to all the user's files.
Re:Fuchsia IDL Overview by guiriduro on Thursday March 17, 2022 @08:55AM (#30710617)
Well, thinking around why you'd pass around a local FD among some processes via IPC, what are the typical use cases? As a source/sink in a chain of piped processes? the connections are the pipes, not the file except at the ends. Perhaps several services cooperating to differentially process parts of a file? you'd probably architect that as a FileService that would wrap the FD and trigger events or stream to individual processing services, and here there's no fundamental difference if it runs RPC or IPC (although IPC throughput can be optimised of course, but done transparently by the ORB.) Whereas an FD-passing IPC solution is locked to local processing anyway (and only vertical scalability), and if you're already paying the price to write IDL for that, isn't the RPC/IPC style solution above both more flexible (allows hz scale), not significantly more complex or locking you into yet another IDL ?
Re:Fuchsia IDL Overview by kllrnohj on Thursday March 17, 2022 @12:03PM (#30712640)
Eh? I literally gave an example - asking the user to pick a file or open a hardware resource (audio stream, for example, or USB device). The trusted system process shows the file picker & opens the file, and then just gives the requesting app that open FD.

It's a pretty straightforward & extendable way to do permission handling, rather than needing the kernel to do all of that natively. Whereas if you go the RPC route, then you're into not just a monolithic kernel but a larger-than-ever monolithic kernel as it's now doing permission management, too.

Re:Fuchsia IDL Overview by dahfizz on Thursday March 17, 2022 @09:03AM (#30710688)
> Like it's not possible to send an open file descriptor across RPC, but it's very possible (and very useful) to do the same over IPC.

Really? I know you can use SCM_RIGHTS on a socket, if that is what you mean. In my mind IPC means shared mmap'd memory, though

Re:Fuchsia IDL Overview by kllrnohj on Thursday March 17, 2022 @12:06PM (#30712677)
Android's Binder driver can send arbitrary FDs as can unix domain sockets via sendmsg. SCM_RIGHTS isn't limited to sending sockets, it can send any FD (open file, open socket, a memfd shared memory buffer, handle to a hardware resource, etc...)
Re:Fuchsia IDL Overview by znwu on Friday March 18, 2022 @04:29AM (#30719807)
There is also the problem of binary layout. RPC values on binary size, and IPC values on latency with zero ser/des. The two binary layouts are simply incompatible. You can do zero copy with RPC, but that does not help with ser/des. FIDL uses a full uint64 just for a discriminated union tag, which is just crazy for any protocol that is going through a cable.
Re:Fuchsia IDL Overview by malkia on Friday March 18, 2022 @09:33PM (#30729991)
if it's IPC only then it avoids the ntohl conversion between different endian machines, or alignments, another one would be shared memory map, and special handling for os objects ("handles", "events", etc.).