D-Bus Benchmark on Raspberry Pi 4B

Building from initial D-Bus testing on the Raspberry Pi, I was looking to understand the performance aspects.

From initial research, it appears like the following are the key delays within D-Bus design:

  • 1-byte ping-pong using UNIX sockets: (10µs)

  • 1-byte (body) D-Bus message ping-pong: (225µs)

Here is a verbatim quote from the abstract of his presentation on kdbus

D-Bus is a powerful design. However, being mostly a userspace solution its latency and throughput are not ideal. A full transaction consisting of method call and method reply requires 10 (!) copy operations for the messages passed. It is only useful for transfer of control messages, and not capable of streaming larger amounts of data.

Benchmark

I used the following as a basis for the benchmarking: https://github.com/matthoosier/dbus-benchmarks

The benchmark software simply takes a before and after timestamp. For each client message, it blocks waiting for a response before continuing. The server component simply echoes the same content.

I modified slightly to allow changes in message quantity and size.

Take-Aways

The results seem to be consistent with the brief amount of research performed. This is quite slower than expected, but should be sufficient for what I’m looking to use it for.

It also appears that kdbus has failed and been abandoned. BUS1 is the named successor, but unclear whether it has hit mainline yet.

Code

https://github.com/echozulucode/rpi-dbus-test

Update – dbus-broker

Upon further research, I found that BUS1 appears to still not be in the kernel, but appears that dbus-broker was developed to improve performance. See https://github.com/bus1/dbus-broker/wiki.

pi@raspberrypi:~ $ sudo apt install dbus-broker
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  dbus-broker
0 upgraded, 1 newly installed, 0 to remove and 20 not upgraded.
Need to get 128 kB of archives.
After this operation, 381 kB of additional disk space will be used.
Get:1 http://mirrors.gigenet.com/raspbian/raspbian bullseye/main armhf dbus-broker armhf 26-1 [128 kB]
Fetched 128 kB in 1s (172 kB/s)
Selecting previously unselected package dbus-broker.
(Reading database ... 99630 files and directories currently installed.)
Preparing to unpack .../dbus-broker_26-1_armhf.deb ...
Unpacking dbus-broker (26-1) ...
Setting up dbus-broker (26-1) ...
Replacing the running dbus-daemon with dbus-broker requires a reboot:
please reboot the system when convenient.
Created symlink /etc/systemd/user/dbus.service → /usr/lib/systemd/user/dbus-broker.service.
Created symlink /etc/systemd/system/dbus.service → /lib/systemd/system/dbus-broker.service.
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for systemd (247.3-6+rpi1) ...
pi@raspberrypi:~ $ dbus-broker --help
dbus-broker [GLOBALS...] ...

After a reboot, I re-ran the test with slightly improved response times.