question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Increasing CPU usage over time

See original GitHub issue

Describe Your Problem: I have noticed that homebridge’s cpu consumption is slowly but surely growing over time:

image

(homebridge is the teal colored, increasing item. dips to 0% are when I have restarted the host pi4)

I was wondering if anyone has seen similar behavior. Not sure if it is connected to homebridge or the homebridge-mqttthing plugin (the only one I am using).

Logs: I have noticed nothing special in the logs, no errors, etc:

[9/3/2020, 4:01:24 AM] [Dishwasher2] Initializing mqttthing accessory...
[9/3/2020, 4:01:24 AM] [livingroom] Initializing mqttthing accessory...
[9/3/2020, 4:01:24 AM] [bedroom] Initializing mqttthing accessory...
[9/3/2020, 4:01:24 AM] [entrydoor] Initializing mqttthing accessory...
[9/3/2020, 4:01:24 AM] [livingsliding] Initializing mqttthing accessory...
Setup Payload:
X-HM://0023OSNLD56PA
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ xxx-xx-xxx │     
    └────────────┘     
                       
[9/3/2020, 4:01:24 AM] Homebridge is running on port 51826.
[9/14/2020, 10:57:16 PM] [HB Supervisor] OS: Linux 5.4.51-v7l+ arm
[9/14/2020, 10:57:16 PM] [HB Supervisor] Node.js v12.18.3 /usr/local/bin/node
[9/14/2020, 10:57:16 PM] [HB Supervisor] Homebridge Path: /usr/local/lib/node_modules/homebridge/bin/homebridge
[9/14/2020, 10:57:16 PM] [HB Supervisor] UI Path: /usr/local/lib/node_modules/homebridge-config-ui-x/dist/bin/standalone.js
[9/14/2020, 10:57:16 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /homebridge/node_modules
[9/14/2020, 10:57:16 PM] [HB Supervisor] Started Homebridge v1.1.3 with PID: 406

Homebridge Config:

{
    "mdns": {
        "interface": "192.168.20.19"
    },
    "bridge": {
        "name": "Homebridge",
        "username": "0E:4E:E3:xx:xx:xx",
        "port": 51826,
        "pin": "xxx-xx-xxx"
    },
    "accessories": [
        {
            "accessory": "mqttthing",
            "type": "switch",
            "name": "Front door",
            "url": "mqtt://192.168.20.15:1883",
            "username": "",
            "password": "",
            "topics": {
                "getOn": "homebridge/state/frontdoor",
                "setOn": "homebridge/control/frontdoor"
            },
            "onValue": "on",
            "offValue": "off",
            "logMqtt": false
        },
        {
            "accessory": "mqttthing",
            "type": "switch",
            "name": "Arriving home",
            "url": "mqtt://192.168.20.15:1883",
            "username": "",
            "password": "",
            "topics": {
                "getOn": "homebridge/state/arrivinghome",
                "setOn": "homebridge/control/arrivinghome"
            },
            "onValue": "on",
            "offValue": "off",
            "logMqtt": false
        },
        {
            "accessory": "mqttthing",
            "type": "outlet",
            "name": "Dishwasher2",
            "url": "mqtt://192.168.20.15:1883",
            "mqttOptions": {
                "keepalive": 30
            },
            "mqttPubOptions": {
                "retain": true
            },
            "topics": {
                "getOn": "tasmota/stat/sonoff-dishwasher/POWER",
                "setOn": "tasmota/cmnd/sonoff-dishwasher/power",
                "getOnline": "tasmota/tele/sonoff-dishwasher/LWT",
                "getWatts": {
                    "topic": "tasmota/tele/sonoff-dishwasher/SENSOR",
                    "apply": "return JSON.parse(message).ENERGY.Power;"
                },
                "getVolts": {
                    "topic": "tasmota/tele/sonoff-dishwasher/SENSOR",
                    "apply": "return JSON.parse(message).ENERGY.Voltage;"
                },
                "getAmperes": {
                    "topic": "tasmota/tele/sonoff-dishwasher/SENSOR",
                    "apply": "return JSON.parse(message).ENERGY.Current;"
                }
            },
            "history": "false",
            "logMqtt": false,
            "onValue": "ON",
            "offValue": "OFF",
            "onlineValue": "Online",
            "startPub": {
                "tasmota/cmnd/sonoff-dishwasher/power": ""
            },
            "manufacturer": "ITEAD",
            "model": "Sonoff POW",
            "serialNumber": "XXXXXXXX"
        },
        {
            "accessory": "mqttthing",
            "type": "temperatureSensor",
            "name": "livingroom",
            "url": "mqtt://192.168.20.15:1883",
            "caption": "Living room temperature",
            "topics": {
                "getCurrentTemperature": "homebridge/status/temperature/livingroom"
            }
        },
        {
            "accessory": "mqttthing",
            "type": "temperatureSensor",
            "name": "bedroom",
            "url": "mqtt://192.168.20.15:1883",
            "caption": "Bedroom temperature",
            "topics": {
                "getCurrentTemperature": "homebridge/status/temperature/bedroom"
            }
        },
        {
            "accessory": "mqttthing",
            "type": "contactSensor",
            "name": "entrydoor",
            "url": "mqtt://192.168.20.15:1883",
            "caption": "Entry door",
            "topics": {
                "getContactSensorState": "homebridge/status/contactsensor/entry"
            },
            "integerValue": true
        },
        {
            "accessory": "mqttthing",
            "type": "contactSensor",
            "name": "livingsliding",
            "url": "mqtt://192.168.20.15:1883",
            "caption": "Sliding door",
            "topics": {
                "getContactSensorState": "homebridge/status/contactsensor/livingsliding"
            },
            "integerValue": true
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 80,
            "auth": "none",
            "host": "192.168.20.19",
            "restart": "sudo -n systemctl restart homebridge",
            "sudo": true,
            "log": {
                "method": "systemd"
            },
            "platform": "config"
        }
    ]
}

Screenshots:

Environment:

  • Node.js Version: v12.18.3
  • NPM Version: v6.14.6
  • Homebridge Version: 1.1.3
  • Operating System: Docker on a pi4
  • Process Supervisor: Docker

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:56 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
ebaauwcommented, Jan 22, 2022

Without knowing the structure of what homebridge does with its threads I can’t know, but it seems plausible that these four threads correspond to the plugins (they do show an up-tick in CPU when I use them). Note, no huge (or unbalanced) CPU TIME accumulation for these, just the main homebridge process.

The threads are spawned by NodeJS, mainly to do I/O and compute-intensive stuff without blocking the main thread. You’ll see them for any NodeJS application. Homebridge is completely unaware of this, and there’s no relation between a plugin and a thread.

For details, see http://docs.libuv.org/en/v1.x/design.html.

1reaction
rbswiftcommented, Jan 16, 2022

Do you have both wifi and wired Ethernet connected to the same network? I found this caused problems for me and my CPU creep immediately abated after running ifconfig wlan0 down.

I haven’t investigated further but could be some kind of broadcast/multicast loop happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix High CPU Usage - Intel
Updating your drivers may eliminate compatibility issues or bugs that cause increased CPU usage. Open the Start menu, then Settings.
Read more >
How to Check, Lower or Increase CPU ... - The Windows Club
2] How to increase or Maximize CPU usage in Windows 11/10 · Go to Control Panel > Power Options > Change Plan Settings....
Read more >
How to Maximize CPU Usage - Techwalla
Click the "Advanced" link next to "High Performance." Scroll down to the "Minimum CPU Usage" field. Ensure the value entered in this field...
Read more >
How to Fix High CPU Usage (with Pictures) - wikiHow
1. Press .Ctrl+ Shift+Esc to open the Task Manager. This is a utility that monitors and reports on all of the processes and...
Read more >
Guidance for troubleshooting high CPU usage - Windows Server
Introduces general guidance for troubleshooting scenarios in which you experience high CPU usage.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found