Products › lamco-dbus-tools › Use cases
Slow D-Bus call: Is it the bus or the service?
Slow D-Bus call: Is it the bus or the service? Time it at the caller and at the bus, then split each call at each socket with the kernel part, using dbustell.
Most answers come back in a third of a millisecond at the caller, but one in twenty takes 15 ms, and the
service's developers and the machine's administrator each blame the other. lamco-dbus-tools settled it with
dbussee, which recorded the bus with the kernel's stamps, dbusdo, which made the 300 calls,
dbustell, which split each call at each socket, and dbuskeep, whose kernel part stamped every
message.
A real run on 2026-12-01 on Debian 13 (a test VM, kernel 6.12.118, dbus-daemon 1.16.2), with a development
build of lamco-dbus-tools, version 0.1.0. run.sh ran it, lookup.py and flood.py are the
made-up service and load, not a real application, and the outputs are in the use case's directory as
they were printed.
The symptom
A program calls com.example.Lookup.Find and most answers come back in a third of a millisecond at the caller, but one in
twenty takes 15 ms. The service's developers say the service is fast and the bus must be slow; whoever runs
the machine says the bus is fine. Both can be right on some machine, so the question is which is right on
this one.
What the caller's and the bus's figures can't settle
Timing the calls from both ends, as dbustell timing --caller does, gives the caller's figure
and the span between the bus passing the call on and passing the answer back:
$ dbussee --quiet --address "$BUS" record --all --kernel --no-host --duration 6 --out slow-service-rec.json &
$ dbusdo --quiet --address "$BUS" --out slow-service-acts.json call --repeat 300 com.example.Lookup /lookup com.example.Lookup.Find s x
$ wait
$ dbustell timing slow-service-rec.json --caller slow-service-acts.json --split
300 of the caller's 300 calls are in the recording, joined by the caller's name and the call's serial. On one machine's monotonic clock:
At the caller min 274.56 µs median 353.71 µs 95th 15.53 ms 99th 15.67 ms max 15.71 ms
At the bus min 82.7 µs median 248 µs 95th 15.43 ms 99th 15.53 ms max 15.71 ms
Both trips together min 0 ns median 101.72 µs 95th 159.06 µs 99th 220.02 µs max 277.92 µs
At the caller is from sending the call to reading its answer; at the bus, from the bus passing the call on to it passing the answer on, as the recorder saw them, each good to ± 7.67 µs. Both trips together are the first less the second: The call's way to the bus and the answer's way back.
The distributions agree: At each percentile, minimum to the 95th, the span at the bus is no longer than at the caller, within that. A percentile is judged with at least ten calls above it, so a few late stamps can't decide it: The 99th needs 1,000 calls, these are 300. 156 calls' answers the recorder read after the caller did, by up to 83.76 µs: Each is judged by its span at the bus less that, the least its stamp was late by. The maximum is one call, and any error on it is that call's.
How the trips split between the way out and the way back isn't known better than 91.43 µs: The recorder read some answers that long after the caller did, so its stamps run late by at least that.
Split by the kernel's stamps at each socket: 300 of 300 calls followed through all eight.
in the bus, both ways: median 53.2 µs, 95th 68.82 µs, max 101.7 µs
in the service: median 183.99 µs, 95th 15.32 ms, max 15.44 ms
across the four sockets: median 80.5 µs, 95th 128.63 µs, max 164.04 µs
the caller's own time: median 26.78 µs, 95th 51.52 µs, max 87.59 µs
the caller's figure: median 353.71 µs, 95th 15.53 ms, max 15.71 ms
Each gap:
caller to bus: median 18.38 µs, 95th 38.24 µs, max 53.06 µs
in the bus, the call: median 26.91 µs, 95th 38.63 µs, max 63.26 µs
bus to service: median 16.33 µs, 95th 33.83 µs, max 42.96 µs
in the service: median 183.99 µs, 95th 15.32 ms, max 15.44 ms
service to bus: median 19.64 µs, 95th 40.54 µs, max 54.44 µs
in the bus, the answer: median 24.95 µs, 95th 34.03 µs, max 60.63 µs
bus to caller: median 18.12 µs, 95th 40.27 µs, max 76.05 µs
Every call's eight stamps lie inside its span at the caller, which sums its own time and the kernel's span. A gap from a write to its read is known to within that write's length, at most 20.98 µs here.
The first part is the two ends: The tail is "at the bus", 15.43 ms at the 95th percentile, because the span at the bus runs from the bus passing the call on to it passing the answer back, and the service's work is inside it. That figure says the trips to and from the bus aren't the problem, and nothing about whether the bus or the service holds the time.
The split
The second part, from the kernel's stamps at all four sockets the call crossed, answers it: In the bus,
68.8 µs at the 95th percentile; in the service, 15.32 ms. The service is slow one call in twenty, and the bus
isn't. That's what lookup.py does: Every tenth call sleeps 15 ms.
When it is the bus
The same 300 calls to the same service with its sleep turned off (SLOW=0), on a bus kept busy by another
client: flood.py sends signals as fast as it can, and 20 connections each asked the bus for them, so the bus
copies every signal 20 times. It sent:
flood: 198800 signals sent, each to 20 listeners
$ dbustell timing busy-bus-rec.json --caller busy-bus-acts.json --split
300 of the caller's 300 calls are in the recording, joined by the caller's name and the call's serial. On one machine's monotonic clock:
At the caller min 271.47 µs median 451.52 µs 95th 2.03 ms 99th 3.55 ms max 5.50 ms
At the bus min 235 ns median 272.73 µs 95th 1.83 ms 99th 3.27 ms max 5.49 ms
Both trips together min 0 ns median 179.17 µs 95th 919.11 µs 99th 1.50 ms max 2.78 ms
...
Split by the kernel's stamps at each socket: 300 of 300 calls followed through all eight.
in the bus, both ways: median 51.59 µs, 95th 341.87 µs, max 1.73 ms
in the service: median 188.36 µs, 95th 1.06 ms, max 4.62 ms
across the four sockets: median 98.21 µs, 95th 982.64 µs, max 3.85 ms
the caller's own time: median 17.61 µs, 95th 33.66 µs, max 1.37 ms
the caller's figure: median 451.52 µs, 95th 2.03 ms, max 5.50 ms
Each gap:
caller to bus: median 29.39 µs, 95th 189.19 µs, max 972.24 µs
in the bus, the call: median 27.96 µs, 95th 214.91 µs, max 733.66 µs
bus to service: median 13.05 µs, 95th 97.3 µs, max 1.42 ms
in the service: median 188.36 µs, 95th 1.06 ms, max 4.62 ms
service to bus: median 33.42 µs, 95th 480.94 µs, max 2.53 ms
in the bus, the answer: median 22.73 µs, 95th 187.29 µs, max 1.68 ms
bus to caller: median 10.36 µs, 95th 76.44 µs, max 2.37 ms
Every call's eight stamps lie inside its span at the caller, which sums its own time and the kernel's span. A gap from a write to its read is known to within that write's length, at most 24.36 µs here.
Now the bus's time, split at each socket, has a tail: 341.9 µs at the 95th percentile, five times the quiet bus's, and the four sockets' waits rise from 128.6 µs to 982.6 µs, since every reader waits behind the flood to be woken. The service's time rises too, to 1.06 ms at the 95th, though it never sleeps: The flood's 21 connections and the bus copying for them take the machine's three CPUs, and the service waits for one. The split says where the time went; why the service waited is the machine's load, which the host's own tools show.
What to do
- When the tail is in the service, it's the service's to fix, and the split shows it without touching the service or the bus.
- When the tail is in the bus and the sockets, look for what else the bus is doing:
dbustell signalsgives the recording's signals by sender and kind, how many and how often, and storms, anddbussee statsthe bus's counters and what each connection has waiting to be read. - Run the kernel part only while it's needed: It costs every local stream socket on the machine while it runs (the kernel part's measurements).
How it was run
run.sh starts a private dbus-daemon, the kernel part as user with only CAP_BPF and CAP_PERFMON
(dbuskeep kernel, through setpriv), and for each case the service, a recording with --kernel and
dbusdo's 300 calls. The first time it ran, its binaries were a build without the kernel feature: The service
said so and stopped, each recording's capture said the kernel part wasn't reached, and --split refused
rather than split nothing. The run here is the second, with the right build.