node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

node-red-node-pi-gpio -> nrgpio.py uses ~1% CPU per IO port

Open pebl-hank opened this issue 1 year ago • 3 comments

Node-red: 3.1.8 node-red-node-pi-gpio: 2.0.6 Nodejs: 20.12.1 Raspberry Pi 5 (64bit)

My flow uses multiple "rpi-gpio in" nodes to monitor if an IO port is 0 or 1. Debouncing is set to 100mS (changing this value seems not to solve the issue). The issue is that htop shows 4 "nrgpio.py" process per IO line that is configured in the node-red flow. That are about 40 processes. 1 of each 4 processes continously has a CPU usage of about 0.7 up to 2%. So 10 processes use around 1% each on average.

I did not notice that issue on my Raspberry Pi 4 that ran a 32bit OS.

Is that something that can be fixed in this module?

Example: [ { "id": "a95c2f4d.c0168", "type": "rpi-gpio in", "z": "bb3e7715.2c09", "name": "bad", "pin": "26", "intype": "down", "debounce": "100", "read": true, "bcm": true, "x": 90, "y": 700, "wires": [ [ "b860d764.0aea98", "a65e9d62ead68e73" ] ] }, { "id": "728b682e.a4b2c", "type": "rpi-gpio in", "z": "bb3e7715.2c09", "name": "wohn", "pin": "16", "intype": "down", "debounce": "100", "read": true, "bcm": true, "x": 90, "y": 640, "wires": [ [ "9b4d24c4.8bd2f", "a65e9d62ead68e73" ] ] }, { "id": "17b463b.93fcc1c", "type": "rpi-gpio in", "z": "bb3e7715.2c09", "name": "schlaf", "pin": "21", "intype": "down", "debounce": "100", "read": true, "bcm": true, "x": 90, "y": 520, "wires": [ [ "c8aba6f6.5eb048", "a65e9d62ead68e73" ] ] }, { "id": "a65e9d62ead68e73", "type": "debug", "z": "bb3e7715.2c09", "name": "debug 51", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 420, "y": 640, "wires": [] } ]

pebl-hank avatar Apr 04 '24 10:04 pebl-hank

I'm had this as well on a Pi3B+ with quite modest GPIO usage; two input pins monitored for changes and one pin used to output a PWM signal. I had at some point added duplicates of the input pins on a separate flow for troubleshooting reasons - removing these dropped total CPU usage dramatically from ~50% to under 10%. 15 min load average is down to 0.1 from 1.7! It seems these nodes conflict somehow when you have duplicates...

clickworkorange avatar Sep 03 '24 15:09 clickworkorange

I double checked the nodes for dublicate pins. There was one that was disabled. I removed it, but no luck in my case. Thanks for the suggestions though!

pebl-hank avatar Sep 07 '24 06:09 pebl-hank

I'm using a Raspberry Pi 3 Model B Plus Rev 1.3 with Debian 11.11 and a lot of inputs. There are 2 python3 threads for each input. htop shows 0% CPU for each. Same hardware with Debian 12.8 - 4 threads for each input and two of them with about 2 - 5% CPU! so with 15 inputs I have about 10 degrees more heat. (Clean install, update everything, install node-red) 07-01-2025_14-26-29

helmutacp avatar Jan 07 '25 13:01 helmutacp