Ok, I asked one of the core team members for some help. He pointed me to the following:
System time leaps in VirtualBox guests (laurentiupancescu.com)
Interestingly, the blog even mentions the Mac Mini!
It would seem that HA OS is (probably???) choosing to use TSC for the clock base that ultimately time.monotonic()
uses, whereas Ubuntu must be choosing something different. Further, it would seem that the TSC on your Mac Mini is not of the “invariant” type, meaning it probably stops when the CPU is idle, causing time.monotonic()
, and hence hass.loop.time()
, to get further and further behind real wall time (and time.time()
) the longer the system runs. It is interesting, though, that it always seems to be a factor of 2x. Hmm… Maybe HA OS is picking some other clock source that is unique to VBox, which just happens to be running at 1/2 real speed as opposed to the clock that Ubuntu chooses.
It would be helpful if you could run the following command from Ubuntu and HA OS (both running on VBox):
for clk in available current; do cat /sys/devices/system/clocksource/*/${clk}_clocksource; done
FWIW, when I run this command on my (native) Ubuntu system and within the docker container that is running HA, I get:
$ for clk in available current; do cat /sys/devices/system/clocksource/*/${clk}_clocksource; done
tsc hpet acpi_pm
tsc
$ docker compose exec homeassistant bash
bash-5.1# for clk in available current; do cat /sys/devices/system/clocksource/*/${clk}_clocksource; done
tsc hpet acpi_pm
tsc
FWIW, my system is using an Intel(R) Core™ i7-2760QM CPU (from /proc/cpuinfo).