Bluetooth/D-Bus causing high ping latency

Here is a ping from my Raspberry Pi with Home Assistant to my router over Wifi:

64 bytes from 192.168.42.1: icmp_seq=1 ttl=64 time=16.8 ms
64 bytes from 192.168.42.1: icmp_seq=2 ttl=64 time=81.5 ms
64 bytes from 192.168.42.1: icmp_seq=3 ttl=64 time=11.1 ms
64 bytes from 192.168.42.1: icmp_seq=4 ttl=64 time=4.76 ms
64 bytes from 192.168.42.1: icmp_seq=5 ttl=64 time=126 ms
64 bytes from 192.168.42.1: icmp_seq=6 ttl=64 time=72.1 ms
64 bytes from 192.168.42.1: icmp_seq=7 ttl=64 time=1029 ms
64 bytes from 192.168.42.1: icmp_seq=8 ttl=64 time=689 ms
64 bytes from 192.168.42.1: icmp_seq=9 ttl=64 time=157 ms
64 bytes from 192.168.42.1: icmp_seq=10 ttl=64 time=4.61 ms
64 bytes from 192.168.42.1: icmp_seq=11 ttl=64 time=396 ms
64 bytes from 192.168.42.1: icmp_seq=12 ttl=64 time=105 ms
64 bytes from 192.168.42.1: icmp_seq=13 ttl=64 time=21.0 ms
64 bytes from 192.168.42.1: icmp_seq=14 ttl=64 time=1.79 ms
64 bytes from 192.168.42.1: icmp_seq=15 ttl=64 time=79.4 ms
64 bytes from 192.168.42.1: icmp_seq=16 ttl=64 time=2281 ms
64 bytes from 192.168.42.1: icmp_seq=17 ttl=64 time=2410 ms
64 bytes from 192.168.42.1: icmp_seq=18 ttl=64 time=1387 ms
64 bytes from 192.168.42.1: icmp_seq=19 ttl=64 time=878 ms
64 bytes from 192.168.42.1: icmp_seq=20 ttl=64 time=487 ms
64 bytes from 192.168.42.1: icmp_seq=21 ttl=64 time=153 ms

load average: 0.09, 0.21, 0.29

This problem started when I added -v /run/dbus:/run/dbus:ro to my docker command line, which now reads:

docker run -d \
           --name homeassistant \
           --privileged \
           --restart=unless-stopped \
           -e TZ=Europe/Berlin \
           -v /opt/homeassistant/config:/config \
           -v /run/dbus:/run/dbus:ro \
           --network=host \
           ghcr.io/home-assistant/raspberrypi4-homeassistant:stable

Here’s a ping after I removed the line and restarted HA:

64 bytes from 192.168.42.1: icmp_seq=1 ttl=64 time=1.47 ms
64 bytes from 192.168.42.1: icmp_seq=2 ttl=64 time=1.41 ms
64 bytes from 192.168.42.1: icmp_seq=3 ttl=64 time=5.20 ms
64 bytes from 192.168.42.1: icmp_seq=4 ttl=64 time=12.5 ms
64 bytes from 192.168.42.1: icmp_seq=5 ttl=64 time=1.39 ms
64 bytes from 192.168.42.1: icmp_seq=6 ttl=64 time=1.48 ms
64 bytes from 192.168.42.1: icmp_seq=7 ttl=64 time=1.66 ms
64 bytes from 192.168.42.1: icmp_seq=8 ttl=64 time=1.97 ms
64 bytes from 192.168.42.1: icmp_seq=9 ttl=64 time=4.12 ms
64 bytes from 192.168.42.1: icmp_seq=10 ttl=64 time=1.29 ms
64 bytes from 192.168.42.1: icmp_seq=11 ttl=64 time=1.43 ms
64 bytes from 192.168.42.1: icmp_seq=12 ttl=64 time=5.38 ms
64 bytes from 192.168.42.1: icmp_seq=13 ttl=64 time=1.48 ms
64 bytes from 192.168.42.1: icmp_seq=14 ttl=64 time=25.2 ms
64 bytes from 192.168.42.1: icmp_seq=15 ttl=64 time=35.5 ms
64 bytes from 192.168.42.1: icmp_seq=16 ttl=64 time=1.82 ms
64 bytes from 192.168.42.1: icmp_seq=17 ttl=64 time=1.52 ms
64 bytes from 192.168.42.1: icmp_seq=18 ttl=64 time=0.976 ms
64 bytes from 192.168.42.1: icmp_seq=19 ttl=64 time=1.20 ms
64 bytes from 192.168.42.1: icmp_seq=20 ttl=64 time=29.9 ms

load average: 0.45, 0.52, 0.39

It doesn’t seem to be purely a CPU issue, I have added load averages to the listings above. (They are from different times after HA startup, I just wanted to demonstrate that the load isn’t higher with the mount.) HA doesn’t show up in top particularly different with and without the mount either.

It’s a Raspberry Pi 4 Model B Rev 1.4, so 4 cores.

I can reliably reproduce this, as soon as I add the mount, the spikes begin, when I remove it, they go away. In fact I can tell whether the dbus directory is mounted or not just by looking at the ping. :slight_smile:

The spikes do not coincide with SD card throughput as reported by iostat. The SD card is mostly idle.