5 ms·
DBus and Systemd
- bheadmaster 2y agoI wish DBus used a pseudo-filesystem approach with plaintext commands in a Plan9 manner - so you could call DBus object methods just by opening a file and writing/reading from it. There are probably reasons why DBus is implemented the way it is, but it just doesn't feel elegant at all.
- actionfromafar 2y agoIt's the unix way /s COM (dbus) + Registry & services (systemd)
- pjmlp 2y agoWhile you are joking, COM was born out of the UNIX way, more precisely Distributed Computing Environment. https://en.wikipedia.org/wiki/Distributed_Computing_Environment https://en.wikipedia.org/wiki/Distributed_Computing_Environm... Then we had that great experience called Taligent https://en.wikipedia.org/wiki/Taligent https://en.wikipedia.org/wiki/Taligent And naturally CORBA, https://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture https://en.wikipedia.org/wiki/Common_Object_Request_Broker_A... NeXTSTEP's Portable Distributed Objects https://en.wikipedia.org/wiki/Portable_Distributed_Objects https://en.wikipedia.org/wiki/Portable_Distributed_Objects Which inspired Sun's Distributed Objects Everywhere written in Objective-C, followed by its reboot in Java as Enterprise JavaBeans. https://en.wikipedia.org/wiki/Distributed_Objects_Everywhere https://en.wikipedia.org/wiki/Distributed_Objects_Everywhere
- mort96 2y agoWould you prefer DBus to be implemented in the kernel then, or would you think that the DBus daemon should expose that pseudo-filesystem using FUSE? Neither of those things seems completely optimal to me to be honest. And it somehow feels very non-Linux that an open syscall or a readdir syscall should be able to block indefinitely as the desktop environment shows a permission syscall...
- sph 2y ago> Would you prefer DBus to be implemented in the kernel Wasn't Greg KH himself trying to explore this? I think it was called Bus1.
- mort96 2y agoMy understanding is that kdbus was mostly a new transport mechanism, so that the dbus daemon didn't have to implement all of dbus's features on top of unix sockets? I don't think there was an attempt to put the whole daemon in kernel space, and there certainly wasn't talk of exposing DBus as a VFS AFAIK Though I haven't read about kdbus in a long time, so I might be misremembering or have misunderstood something back when I read about it. Regardless, I was asking what bheadmaster would've preferred, and if the answer is "the dbus daemon should have been implemented in kernel space and that's what kdbus was trying to do" then that's fine.
- p_l 2y agokdbus etc. was all about making "faster" dbus back when the original dbus-daemon implementation was "too slow (for our corporate sponsors[1])" so there was unresearched push to put dbus into kernel. Involved special things, including even new syscalls (some I think even got refactored out and actually became part of the ABI). Ultimately it got nuked because the code was considered problematic, and performance turned out to not require kernel code. [1] AFAIK mainly automotive companies that were porting, for some reason, QNX IPC over to D-Bus instead of updating a pre-existing "QNX IPC on Linux" code, and I think Binder didn't surface fast enough for this porting effort.
- blucaz 2y agoNo, performance wasn't the main reason (although that was a big part), it was mainly about race conditions. If userspace implements the bus, then only the half of userspace that comes up after the daemon can use it. Having a reliable IPC mechanism that is available from the moment PID1 is started was the goal. Sadly that was rejected, and Bus1 was too, because apparently it's really bad to have IPC primitives in the kernel, can't have that. Then of course 6 months later Google showed up with a few wheelbarrows of cash and Binder, and strangely all such objections evaporated and it was merged without a peep. Funny how these things go.
- blahgeek 2y agoI guess it would be interesting to implement this for DBUS using FUSE.
- XorNot 2y agoExcept Linux hasn't really done this for a while. Most things in Linux are managed via some type of message parsing these days anyway - i.e. you don't configure devices - really - by /dev/ entries, instead you use the /dev/ entry as the target for an ioctl call which basically does whatever it wants. It's not really file-like at all. Then there's network which is configured usefully by netlink, which is another message passing protocol. It doesn't seem like an accident that we keep reinventing socket-based messaging protocols to manage systems, and just "forgetting" to do it the Plan9 way.
- bheadmaster 2y agoFrom client perspective, socket I/O is isomorphic to the file I/O - you get a file descriptor and you read/recv and write/send to it. The only difference is how servers handle it. The ioctl() is different, mostly because it's used to share memory between kernel and userspace, but the same communication pattern could be implemented in file I/O too, probably with performance penalty. Just send the serialized structures, and receive them back. But the goal of DBus was never performance, it was to provide a unified interface to global system services. File I/O here seems like an obvious choice - it's the most fundamental interface that almost every program in the world supports.
- mike_hearn 2y agoPlan9 doesn't use plain text commands really. Look at how various services work and you'll find there's usually a C library wrapping the underlying pseudo-file. Plan9 was IMHO to a large extent a failed experiment; the filesystem API wasn't extended enough to be able to express enough operations (e.g. no transactions). The other problem with Plan9 style designs it the concept of filesystem servers. This kills off a lot more expressiveness still e.g. you can't move device files around to organize them better because they aren't really files and the layout is fixed by the server. A dbus that exported stuff via the FS would have the same problem. It'd be full of "files" that you can't rename, move, delete, add xattrs to, read, etc. Most of the operations you can do on files just wouldn't work so what's the point.
- sph 2y agoWe need another variation of the rule: "Any sufficiently advanced desktop operating system contains an informal, buggy implementation of half of Smalltalk" DBus, COM, various UNIX IPC mechanisms & co. are a lot of bureaucracy to do a very simple job: connecting two things and letting them communicate, without caring about the semantics of messaging, or protocols. DBus is crucial to making a fully-featured desktop, but that's a lot of work to send some typed data to another process. Despite the complexity and ceremony, more and more thing depend on DBus because communication among disparate actors is such a useful concept. We have spent the last 60 years in this field focused on honing methods of computation, while communication is something that's tacked on at the end. Now, deep in the Internet age, with fast-enough multicore networked machines, we need a lot of boilerplate to do something all our software depends on. [1] It should be the other way around: communication should be as easy, for the programmer, as adding two integers. (I am working on this space, as I have been obsessed with this question for a long while.) --- 1: even a number-crunching monolith written in high-performance C++ needs to communicate its result to the user or some other remote service. How many lines of code to do that?
- cjk2 2y agoI quote Fowler's ancient First Law of Distributed Object Design: "don't distribute your objects". Any distribution results in masked complexity and many hard to reason about scenarios even if the language or platform supports it transparently. Ergo, just because you can doesn't mean you should, unless you want to discover them all, usually at an inconvenient point in the future when everything is broken and there's cash bleeding out of your org somewhere.
- Xeamek 2y agoWhat about 'standalone' dbus, without systemd? Is it even possible anymore to build dbus without systemd as a dependency?
- mort96 2y agoOne of the ideas behind dbus (and one of the ideas behind systemd! They're sorta linked in this way) is that services should be able to activate on request, like httpd but for local IPC. You could make a stand-alone dbus, but you'd have to either give up on socket activation, or re-implement half of the systemd service manager to make the dbus server responsible for spawning socket activated daemons. Both of those are totally possible and would probably be interesting for non-Linux systems.
- Xeamek 2y agoIt's also the case that there exist non-systemd based linuxes. I mean sure, the self-start is important feature, but I'd rather have a dbus with which I need to start services manually, then have no dbus at all :( Also, why the fuck can't systemd run in chroot.
- nxobject 2y agoBecause of that deep integration with systemd-boot, of course. /s (Yes, I know systemd at this point is just an umbrella brand; I'm no systemd hater.)
- mariusor 2y agoProbably because chroot does not expose some sort of low-level knob that systemd relies on to work. They had to make their own implementation of that in systemd-nspawn, have a look at that.
- Xeamek 2y agoYes, but to use systemd-nspawn, your host must be running systemd to begin with.
- micw 2y agoI learned a bit about dbus when I was scripting the controller of my home battery (victron energy, I use their "venus os" linux on a raspberry pi). I like the discoverability of dbus. One can just query the bus and talk with all registered services, using any client. But it also seems to have significant flaws. One is that there seems not to be any valid timeout/keepalive concept for dbus over TCP. If a registered component is disconnected without gracefully signing off, the resource keeps registered for a long time and cannot easily replaced if the client re-connects after a while.
- DesiLurker 2y agoI wonder what happened to Bus1 [1] and other kdbus type proposals. Would be useful to have an android binder like ipc subsystem. 1. https://lwn.net/Articles/697191/ https://lwn.net/Articles/697191/ 2. https://lwn.net/Articles/580194/ https://lwn.net/Articles/580194/
- p_l 2y agoBinder is honestly much better than D-Bus, but for various reasons I don't think we're going to see it much on desktop (though you can, in fact, use it there - and it originates from exactly such use). The kdbus finally died when Linus sat down and proved that: 1) then-current userspace d-bus code was simply horrible which led to kdbus being mainly about speed/latency, but... 2) Linus spent a weekend and got an userspace dbus server 80/20 solution that achieved better performance than kdbus and 3) kdbus introduced no real new benefits that weren't ultimately triggered by "dbus is too slow", unlike Binder which involves fancy scheduling tricks to pass CPU quanta from one process to another along with RPC call. Thus the final nail in coffin of kdbus (which was previously hampered by being considered too problematic to merge) was hammered in.
- blucaz 2y agokdbus/bus1 were about making IPC primitives available race-free to userspace since the very first moment it is started. Perf was icing on the cake. Binder is Google-only, so nobody else can really use it, given they might kill it at any moment. The end result of not having bus1 is that we have to forget about brokered IPC and go back to 1:1 bespoke protocols over af_unix - ie, varlink
- p_l 2y agoBinder has been mainlined since a bit before kdbus project started, and can be in fact utilized with alternate implementations, as the kernel interface is explicitly not married to any specific content of the IPC.
- wahern 2y agoLinux did get memfd, which was originally a component of kdbus. kdbus seems to have failed because of arguments over attaching process capabilities to messages: https://lwn.net/Articles/641275/ https://lwn.net/Articles/641275/ And most if not all of the performance improvements were later realized with an improved user space D-Bus implementation (sd-bus?). bus1 seems to have followed a similar trajectory--what remains of the effort is a better D-Bus implementation in user space: https://github.com/bus1/dbus-broker https://github.com/bus1/dbus-broker
- cjk2 2y agoThis always feels like DBus=DCOM, systemd=Service manager, journald=Event log. And that makes me feel a little dirty.
- pjmlp 2y agoIf it makes you more clean you can use instead: DBus=CORBA(remember Bonobo and Orbit), systemd=Service Management Facility, journald=rsyslogd.
- dale_glass 2y agoHating something just because Microsoft did something like it at some point is silly. IMO all of those are absolutely excellent ideas. Like journald is much better than what came before it, and DBus is much better than poking processes with signals, or having to talk some special protocol to each particular service.
- cjk2 2y agoIt's not the vendor. They were incredibly stateful and opaque which caused numerous problems.
- amelius 2y agoEvery application made with dbus in mind seems to break when I run it remotely. For example, "eog" (eye of gnome) always either breaks or is incredibly slow.
- deleted 2y ago[deleted]
- jauntywundrkind 2y agoWorth pointing out that there's now a second bus in systemd, varlink. https://www.freedesktop.org/software/systemd/man/latest/varlinkctl.html https://www.freedesktop.org/software/systemd/man/latest/varl... https://varlink.org/ https://varlink.org/ Varlink is a bit simpler, I'd say. It's more about individual services opening their own listening sockets, although there is an optional broker too. This somewhat simplifies the addressing model, a little. Messages are in JSON. More and more of the systemd internals are being written or rewritten to rely on varlink for IPC, and the scuttlebutt is that eventually there's a goal to be able to run dbus free.
- zzo38computer 2y agoI think that using JSON is rather inefficient and restrictive compared with using a binary format.
- jauntywundrkind 2y agoUsing complex custom binary encodings is an inefficient use of human's time. It's error prone. The constraints are well known & optimized for. The binary protocol will also have people implementing their own, poorly. Where-as one can get piping hot SIMD optimized JSON encoder/decoders. I'm not 100% JSON all the time. But this response strikes me as crufty neckbeardy shit that ignores the obvious & good & uses negativity to step on a pretty clear & straightforward path. Having use d-feet & busctl dozens of times in my life, it's miserable. The encoding scheme is terrible & unpleasant. JSON is an obvious counter reaction, to try to make some damned sense. Given that these bus capabilities are more control plane than data plane (but it's not a hard line), it's ok.
- zzo38computer 2y agoA binary format does not need to be complicated, and does not need to be the same as D-Bus (which has many problems). Furthermore, it can avoid some of the things in JSON, e.g. requiring escaping, requiring Unicode, not properly supporting 64-bit integers, embedded binary data cannot be made directly, etc.
- hommelix 2y agoThere is as well ubus from openwrt for inter process communication. https://openwrt.org/docs/techref/ubus https://openwrt.org/docs/techref/ubus