elad-bar / ha-blueiris

Integration with Blue Iris Video Security Software
184 stars 43 forks source link

High BI CPU Usage When Intergration is Active. #160

Closed RJ-Make closed 2 years ago

RJ-Make commented 2 years ago

Not sure when this started but.

I'm seeing significantly higher BlueIris CPU usage anytime the integration is enabled (after a HA restart) BI CPU consumption goes from a normal ~3% to a whoping ~35%. Once I shut the integration down (after a HA restart) BI CPU consumption returns to ~3%.

This is with no camera cards in Home Assistant.

Windows 10 Pro, HAOS Running inside VirtualBox.

System Health

version core-2022.3.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.9
os_name Linux
os_version 5.10.98
arch x86_64
timezone America/New_York
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4918 Installed Version | 1.23.0 Stage | running Available Repositories | 1008 Downloaded Repositories | 9
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | March 21, 2022, 8:00 PM relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true remote_server |XX can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 7.4 -- | -- update_channel | stable supervisor_version | supervisor-2022.03.3 docker_version | 20.10.9 disk_total | 30.8 GB disk_used | 13.0 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Samba share (9.5.1), Studio Code Server (4.1.0), InfluxDB (4.3.0), File editor (5.3.3), Nextcloud Backup (0.16.8), SSH & Web Terminal (10.0.2), Samba Backup (5.0.0), Z-Wave JS (0.1.54), Z-Wave JS to MQTT (0.36.0), Network UPS Tools (0.9.1), MariaDB (2.4.0), Zigbee2mqtt (1.24.0-1)
Lovelace dashboards | 1 -- | -- resources | 3 views | 7 mode | storage
kramttocs commented 2 years ago

There must be some streaming going on somewhere. Otherwise the integration is just making json calls on a polling interval which wouldn't have that kind of CPU impact. Do you see the same behavior if you disable the integration and load up UI3 from Blue Iris?

RJ-Make commented 2 years ago

Thanks for the suggestion.

When I open UI3, I get a ~4% increase.

This is what I know.

1) The integration has it's own BI user credentials. If I disable that user in BI and restart HA, BI returns to normal CPU consumption.

2) I have removed all UI cards containing a video stream, problem persists.

3) Disabling the integration does NOT reduce the high BI CPU consumption, I must restart HA to reduce the consumption.

Like something in the integration doesn't disconnect when disabled. Perhaps this is normal?

I have a feeling this is going to be a nightmare trying to diagnose.. 😥

RJ-Make commented 2 years ago

I have to leave the integration disabled until I can figure this out.

kramttocs commented 2 years ago

I agree - this one will likely be tough to track down. BI does show if a camera is loaded by the user so maybe that would give us some clue. I'll check CPU changes on my machine, hopefully tonight, to see if I notice a difference. Lot of factors though: # of cameras, quality of cameras, specs of BI server, etc.

RJ-Make commented 2 years ago

As a BI CPU reference point (Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz 3.70 GHz) 5 Cameras

2022-03-13_7-08-19 2022-03-13_7-23-03 2022-03-13_6-55-27 2022-03-13_6-57-02 2022-03-13_6-59-57 2022-03-13_6-52-34 2022-03-13_7-18-29
RJ-Make commented 2 years ago

I think I found what may be the cause. I was thinking what would cause a 2 second cycle through all the camera's non-stop, then I remembered a month or so ago, I select the Support stream component (Requires restart) Option to test out, and then un-ticked it after messing around.

Went back to the setting and it was un-ticked. So I re-ticked it, restarted, un-ticked it and restarted, same result.

So today, I decided to completely wipe the integration off my system, then reinstalled and setup and now it's back running at a normal ~1% overhead.

So it appears there may be a disconnect between the UI and wherever that setting lives. Assuming that setting causes the camera cycles.

kramttocs commented 2 years ago

Nice work! I haven't ever tried that feature but will make a note to. I have noticed the integration does seem to hold on to old deleted cameras so the root cause may be the same or similar. Will try to track that down.

griffincorriher commented 2 years ago

Having the same issue, but the full removal and re-add did not solve it

kramttocs commented 2 years ago

Having the same issue, but the full removal and re-add did not solve it

Unfortunately too many variables in this one to guess at what might need changed in in the integration so can you do some troubleshooting and try to narrow it down? The BI log/connection status may give us some clues to identifying if yours is the same behavior (even if not the same resolution) as RJ-Make.

griffincorriher commented 2 years ago

When I reinstalled today I used the previous version of the integration and my UPS load is back to normal for now.

kramttocs commented 2 years ago

Which version is that?

kramttocs commented 2 years ago

The Blue Iris Status > Connections will likely tell us the most.

For reference, here is a test I did just now.

  1. Closed anything that was connected to HA actively (meaning nothing is viewing it via the browser or app)
  2. Restarted the Blue Iris Service on my Windows Server
  3. Opened BI Connections. HA user is connected but 0 Frames and no Object
  4. Task manager shows BI at roughly 4%
  5. Opened the Overview HA dashboard but haven't scrolled down so no cameras are in view. Still 4%, 0 Frames, no Object
  6. Scrolled down to see the cameras
  7. Cameras loaded and CPU jumps around from 4% to 13% depending upon which camera is in the Object column. Frames and Object column are cycling depending upon which is updating
  8. Close the HA browser tab
  9. CPU back to 4% consistently
  10. Frames and Object don't change. I believe they will eventually clear out
  11. Open UI3 in a browser. CPU goes to 5%. The user shows up in BI Connections with a Frame value and Object=Index

What I am seeing I don't consider unexpected. HA Overview is loading connections per camera* vs UI3 that is showing the single Index camera so there is going to be a difference in server load.

*I don't know if it truly is cycling for updates or if they are all updating constantly and BI Connection can only show one at a time due to the way the Connection UI is structured

My details (here is where it's going to be near impossible to get a baseline for this):

Integration: H264 with Support Stream unchecked 13 hardwired cameras, 1 wireless. Hardware decode = Intel+VPP i9 10900K @ 4.8-4.9GHz, 32GB ram HA is running on this box also via VirtualBox

edalquist commented 2 years ago

Seeing the same issue, the HA stream connection to BI is a massive CPU drain. Unchecking the stream option in the config doesn't appear to fix things either.

kramttocs commented 2 years ago

Do you have any other information that might help track this down? As I am not seeing it (see post above yours) I don't know how to address this.

Ming-A commented 2 years ago

Having a similar issue when streaming cameras from HA, but I don't think its an integration issue. When I stream 7 RTSP streams together on frigate as well, it would bring my CPU from 5% to max 100%

kramttocs commented 2 years ago

Thanks @Ming-A . There have been a few ideas and things that worked for one user but didn't for another in this thread but I don't feel confident that anything points to a defect in the integration. I am going to close this ticket but if anyone that sees the problem is able to provide more information that indicates an issue with the integration, I welcome them to do so. I strongly suggest checking with another software (like frigate) or even engaging BlueIris support also to gather more data points.