D-Bus performance

by havoc

To save people time, here is some already-known info on D-Bus performance.

Please
read
this post
and a
short followup
about the new recursive type
marshaling stuff slowing down those numbers a bit. I think there may
be a couple other relevant mails in the archives, but not finding them
right now.

Be sure the build for performance testing
does not have assertions, verbose mode, etc. enabled.
I’d also avoid caring too much about the DBusGProxy layer as it does a
pile of extra copying and is really convenience-over-performance in
many ways. Not to mention it needs basic sanity work in addition to
performance work.

Historical background: the “D-Bus is faster” and “CORBA is slow” rumors are
purely originated by fanboys, and have never been either the goal or
the case. ORBit2 is nearly as fast as raw sockets.
By contrast, most design decisions of D-Bus
(the central bus daemon, validation in a paranoid/secure way of all
data, certain ordering guarantees, etc.) were
traded off in favor of robustness, decreased resource usage,
convenience, etc. rather than speed.

The only potentially significant speed wins in D-Bus I know of: 1)
D-Bus makes it pretty easy to be fully async and avoid any round
trips, which can be the key performance issue in some cases, in
particular may matter for application startup; 2) the
central bus daemon makes broadcasts/signals more efficient than the
case where any app that wants to broadcast has to connect directly to all listeners.

I should note that the D-Bus robustness-over-speed tradeoff mostly has
to do with the libdbus implementation, not the wire protocol. So
someone who disagreed could do a different implementation.

Finally, I’d encourage profiling the desktop and apps, rather than
D-Bus; I would be surprised if D-Bus showed up much in app profiles,
unless someone starts shoveling giant quantities of data through
it. If someone is doing that then a structural change would probably
work better than optimizing libdbus marshaling code:
dropping D-Bus from that app,
using D-Bus in point-to-point mode instead of through the bus daemon,
using D-Bus async instead of with round trips, or whatever.
Though anyone is of course welcome to optimize the libdbus marshaling code.

(This post was originally found at http://log.ometer.com/2006-07.html#21)

My Twitter account is @havocp.
Interested in becoming a better software developer? Sign up for my email list and I'll let you know when I write something new.