Titel: High CPU usage (~60%) with v4.70.0 – fixed by downgrading to v4.66.8


Environment:

  • Gladys v4.70.0 (auto-updated via Watchtower)

  • Docker on Linux (Ubuntu), network_mode: host

  • MQTT integration with multiple devices (Raspberry Pis)


Problem:

After Watchtower automatically updated Gladys from v4.66.8 to v4.70.0, the container started consuming ~60% CPU constantly – not just at startup, but permanently.

gladys    59.72%

The logs showed a flood of errors at startup:

NotFoundError: DeviceFeature mqtt:xxx not found

These appear to be a timing issue where MQTT retained messages arrive before Gladys has loaded its device feature cache. However, even after the startup errors stopped and logs were clean, CPU remained at ~60%.


Solution:

Downgraded back to v4.66.8 and pinned the version to prevent Watchtower from auto-updating:

yaml

gladys:
  image: gladysassistant/gladys:v4.66.8
  labels:
    com.centurylinklabs.watchtower.enable: "false"
```

After downgrade, CPU dropped immediately to ~4%.
```
gladys    3.90%

Question:

Is this a known issue with v4.70.0? Are there plans to fix the CPU regression? I’d like to update eventually but not if it tanks performance again.

Hi @bamboleate
you must have something wrong because on my side I don’t have any issues with the CPU spiking since version 4.70 (or even before):


And I have Zigbee, Node-RED, Z-Wave and scenes running on Gladys.

What’s your hardware setup to run Gladys? (CPU, RAM, HDD/SSD, etc.)

Hi @mutmut, thanks for checking!

My hardware:

  • Machine: Minisforum UM350 (AMD Ryzen 5 3550H)

  • RAM: 32 GB

  • Storage: several HDDs and SSDs connected

  • OS: Ubuntu 24.04

  • Docker, network_mode: host

The CPU spike is very reproducible on my end. Here’s the before/after:

v4.70.0:

gladys    59.72%

v4.66.8 (same machine, same config, same moment):

gladys    3.90%

I’m running MQTT integration with 3 Raspberry Pis (relay boards + sensors). No Zigbee, no Z-Wave, Node-RED I do use.

One thing I noticed in the logs at startup with v4.70.0:

NotFoundError: DeviceFeature mqtt:xxx not found

This repeats for every MQTT device feature at every startup – looks like retained messages arrive before the device cache is ready. Could this flood of errors be causing the CPU spike? Maybe it’s specific to MQTT setups?

Your hardware is clearly good; on my side I’m on a Proxmox cluster and Gladys is on an LXE (equivalent of a VM, to keep it simple) with 6GB of RAM and 2 vCPU.

I’m not an expert for a thorough analysis, unfortunately.
However, regarding Gladys’s MQTT integration, do you use the internal integration?

Then, what does the debug page say?

If you use MQTT Explorer (for example) to connect to the MQTT broker, do any of your RPi information appear?

Another point, how did you configure your devices in the MQTT integration?


From what I see in the error message, one (or several?) device is not found/recognized; you should check with MQTT Explorer whether it is visible and whether its configuration is still correct in Gladys’s MQTT integration.

Hi @mutmut, thanks for the detailed questions!

Yes, I use the internal MQTT integration in Gladys.

Regarding the NotFoundError messages: I already investigated this thoroughly. The errors appear only at startup and are a timing issue – the MQTT broker delivers retained messages before Gladys has finished loading its device feature cache. After startup, the logs are completely clean and all devices work correctly. The RPis publish correctly, the topics are right, and everything is visible in MQTT Explorer.

The errors are not the cause of my problems – they’re a symptom of the startup timing. And more importantly: the CPU stays at ~60% permanently, not just during the error flood at startup.

The key point is the direct comparison:

  • v4.70.0 → 60% CPU constantly, same errors at startup

  • v4.66.8 → 4% CPU constantly, same errors at startup (timing issue exists in both versions)

So something changed between v4.66.8 and v4.70.0 that causes a CPU regression, at least on my setup with MQTT. The errors at startup are a separate (older) issue.

@bamboleate Many thanks for the report, and sorry for the inconvenience.

Did you try installing any other Gladys releases in between?

Here is the full changelog:

Would you mind upgrading version by version until you find which release introduces the issue?

That would help us pinpoint exactly which version caused the problem, which will make it much easier for us to investigate.