News for hackers. Stuff that matters.
Re:Rethinking the D-Bus Message Bus by Animats on Wednesday August 23, 2017 @02:01PM (#15083669)
We rather consider a bus a set of distinct peers with no global state.

If they've gone that far, they may as well implement QNX messaging, which is known to work well. QNX has an entire POSIX implementation based on QNX's messaging system, so it's known to work. Plus it does hard real time.

The basic primitives work like a subroutine call. There's MsgSend (send and wait for reply), MsgReceive (wait for a request), and MsgReply (reply to a request). There's also MsgSendPulse (send a message, no reply, no wait) but it's seldom used. Messages are just arrays of bytes; the messaging system has no interest in content. Receivers can tell the process ID of the sender, so they can do security checks. All I/O is done through this mechanism; when you call "write()", the library does a MsgSend.

Services can give their endpoint a pathname, so callers can find them.

The call/reply approach makes the hard cases work right. If the receiver isn't there or has exited, the sender gets an error return. There's a timeout mechanism for sending; in QNX, anything that blocks can have a timeout. If a sender exits while waiting for a reply, that doesn't hurt the receiver. So the "cancellation" problem is solved. If you wan to do something else in a process while waiting for a reply, you can use more threads in the sender. On the receive side, you can have multiple threads taking requests via MsgReceive, handling the requests, and replying via MsgReply, so the system scales.

CPU scheduling is integrated with messaging. On a MsgSend, CPU control is usually transferred from sender to receiver immediately, without a pass through the scheduler. The sending thread blocks and the receiving thread unblocks.

With unidirectional messaging (Mach, etc.) and async systems, it's usually necessary to build some protocol on top of messaging to handle errors. It's easy to get stall situations. ("He didn't call back! He said he'd call back! He promised he'd call back!") There's also a scheduling problem - A sends to B but doesn't block, B unblocks, A waits on a pipe/queue for B and blocks, B sends to A and doesn't block, A unblocks. This usually results in several trips through the scheduler and bad scheduling behavior when there's heavy traffic.

There's years (decades, even) of success behind QNX messaging, yet people keep re-inventing the wheel and coming up with inferior designs.

Re:Rethinking the D-Bus Message Bus by tomegun on Wednesday August 23, 2017 @02:07PM (#15083707)
Please note that this is still an implementation of the D-Bus specification, but trying to adhere to the principle of distinct peers. As is explained, this is not entirely possible when implementing D-Bus, so it is nothing more than a guiding principle.
Re:Rethinking the D-Bus Message Bus by AceJohnny2 on Wednesday August 23, 2017 @02:13PM (#15083746)
So, SIMPL?

Synchronous Interprocess Messaging Project for LINUX (SIMPL) is a free and open-source project that allows QNX-style synchronous message passing by adding a Linux library using user space techniques like shared memory and Unix pipes[3] to implement SendMssg/ReceiveMssg/ReplyMssg inter-process messaging mechanisms.

https://en.wikipedia.org/wiki/SIMPL

http://icanprogram.com/simpl/

Re:Rethinking the D-Bus Message Bus by Animats on Wednesday August 23, 2017 @02:19PM (#15083809)
If you do it via pipes, the performance will be terrible. If you do it via shared memory, there's a good chance that one side crashing will take down the other side.

QNX itself implements pipes via messaging.

Re:Rethinking the D-Bus Message Bus by AceJohnny2 on Wednesday August 23, 2017 @03:00PM (#15084151)
This project implements QNX messaging as a kernel module:

https://github.com/martinhaefner/qnxcomm

Can't immediately find any more information about it though, so don't know the maturity.

Re:Rethinking the D-Bus Message Bus by CyberDildonics on Thursday August 24, 2017 @11:00AM (#15090627)
> If you do it via shared memory, there's a good chance that one side crashing will take down the other side.

Having done a fair amount of IPC through shared memory, you'll have to explain this one. One process crashing doesn't destroy a memory mapped file on Linux, OS X, or Windows.

Re:Rethinking the D-Bus Message Bus by transpute on Wednesday August 23, 2017 @02:51PM (#15084088)
Since QNX is proprietary, QNX messaging is likely patent encumbered.

What's a good open alternative, or starting point for new innovation, given current investments in microservice architecture?

  - ZeroMQ (and nanomsg)
  - gRPC (Google)
  - Apache Thrift (Facebook)
  - Finagle (Twitter)
  - L4/seL4 IPC
Re:Rethinking the D-Bus Message Bus by sbierwagen on Wednesday August 23, 2017 @03:21PM (#15084301)
Remember, patents don't last forever. The first release of QNX was 35 years ago. Patents only last 20 years.
Re:Rethinking the D-Bus Message Bus by sametmax on Wednesday August 23, 2017 @04:59PM (#15085076)
The wamp protocol is interesting imo. It's independant a serialisation and transport despite the fact it uses websocket + json by default. It does routed rpc and pub/sub out of the box. But no low level router yet.
Re:Rethinking the D-Bus Message Bus by marqis on Wednesday August 23, 2017 @05:37PM (#15085413)
Check out crossbar.io, it's a broker from the authors of wamp.
Re:Rethinking the D-Bus Message Bus by AceJohnny2 on Wednesday August 23, 2017 @03:18PM (#15084284)
> Since QNX is proprietary, QNX messaging is likely patent encumbered.

Not necessarily. QNX messaging is old enough that patents related to the interface may have expired.

Re:Rethinking the D-Bus Message Bus by transpute on Wednesday August 23, 2017 @04:21PM (#15084708)
Here is one from 2005: https://www.google.com/patents/US20060182137

"An asynchronous message passing mechanism that allows for multiple messages to be batched for delivery between processes, while allowing for full memory protection during data transfers and a lockless mechanism for speeding up queue operation and queuing and delivering messages simultaneously."

Maybe there are older patents that have expired?

Re:Rethinking the D-Bus Message Bus by copperred on Wednesday August 23, 2017 @10:15PM (#15087114)
Agree. As a QNX user and later QNX employee, I really missed the messaging system when I had to go back to Linux. In fact, I spent time writing a QNX-like messaging library now used extensively in our application (at my current job). Although not optimal from a performance perspective, most of the messaging we have is small packets and infrequent sends. I feel that it has really accelerated our app development, and forced a similar design pattern for each thread or "service" within the application. The same result could be had with a library such as Nanomsg.
Re:Rethinking the D-Bus Message Bus by oconnor663 on Wednesday August 23, 2017 @05:54PM (#15085565)
> Receivers can tell the process ID of the sender, so they can do security checks.

Does this run into security corner cases around pid reuse? (Or race conditions like a process dropping it's privileges after sending?) I remember the kdbus authors talking about making a lot of security metadata attach to the message itself, rather than indirecting through a pid, maybe for these reasons?

Re:Rethinking the D-Bus Message Bus by asloma on Wednesday August 23, 2017 @08:58PM (#15086743)
> CPU scheduling is integrated with messaging.

So QNX messaging is implemented in kernel space?

I never really understood why kdbus was rejected from Linux, it seems to only have advantages compared to a user space message bus. The only disadvantage I can come up with is security.

Re:Rethinking the D-Bus Message Bus by sethrin on Wednesday August 23, 2017 @11:04PM (#15087315)
Well, security is a pretty big concern, to be fair. The rejection of kdbus was probably political as much as anything else. However, I think that to the degree that there was any kind of consensus, it was not necessarily a rejection of the idea of a kernel-based message bus entirely, but that this particular effort was not up to the mark. This seems to be a fairly relevant bit on LKML:

https://lkml.org/lkml/2015/6/23/22

Re:Rethinking the D-Bus Message Bus by twoodfin on Wednesday August 23, 2017 @08:29PM (#15086575)
Receivers can tell the process ID of the sender, so they can do security checks.

How do they implement this securely? I can't immediately think of a POSIX-y way for Process A to prove its pid to Process B without involving the kernel.

Re:Rethinking the D-Bus Message Bus by wmf on Wednesday August 23, 2017 @08:38PM (#15086631)
Messaging should be implemented by the kernel.
Re:Rethinking the D-Bus Message Bus by CyberDildonics on Thursday August 24, 2017 @10:42AM (#15090457)
"All problems of scale become a network problem." Sean Parent
Re:Rethinking the D-Bus Message Bus by jnwatson on Thursday August 24, 2017 @06:45AM (#15088999)
As QNX has a microkernel, literally the entire OS, kernel and user space, is designed to support this.
Re:Rethinking the D-Bus Message Bus by eschaton on Wednesday August 23, 2017 @02:33PM (#15083919)
This is basically Mach.
Re:Rethinking the D-Bus Message Bus by Animats on Wednesday August 23, 2017 @02:42PM (#15083986)
No, Mach used unidirectional messaging. There was an RPC system, but it came with some formatting and marshalling stuff. Not sure about MacOS. Apple has an explanation of the five or so IPC mechanisms they ended up with.[1]

[1] https://developer.apple.com/library/content/documentation/Da...