tomaae / homeassistant-truenas

TrueNAS integration for Home Assistant
Apache License 2.0
183 stars 16 forks source link

[Bug] Higher CPU Usage with Master (1f937c8) vs v1.2.5 #142

Closed JagerSprinkles closed 7 months ago

JagerSprinkles commented 7 months ago

Describe the issue

After updating to Master branch commit 1f937c8 for the update check frequency fix I noticed that my Truenas server is now using a lot more CPU than when using v1.2.5 of this integration. On v1.2.5 my idle Truenas CPU load is about 1-2% On 1f937c8 my idle Truenas CPU load is 6-7%

How to reproduce the issue

  1. Install v1.2.5
  2. Wait some time for CPU stats to collect
  3. Install 1f937c8
  4. Wait some time for CPU status to collect
  5. Compare

Expected behavior

CPU usage should remain the same as v1.2.5 where it barely made a difference on the Truenas server. The updates in 1f937c8 seem to have increased CPU usage 3-4x.

Screenshots

Screenshot 2024-02-06 165209

Screenshot 2024-02-06 164822

Screenshot 2024-02-06 164346

Screenshot 2024-02-06 164938

The third and fourth screenshots show the difference before and after installing 1f937c8 and the idle CPU baseline being increased 3-4x.

Software versions

Diagnostics data

Not sure what to collect for this,

Traceback/Error logs

No errors or anything in the logs. I have my log level set to warning and there are no entries about this integration. I can collect info/debug logs if they are required to troubleshoot this issue.

Additional context

No other changes were made to the Truenas or Home Assistant server. I had restarted both as well after changing integration versions with no change in CPU usage.

tomaae commented 7 months ago

oof, thats a lot. what kind of hardware do you use?

Try changing following like to 60 seconds and let me know. update_interval=timedelta(seconds=10),

JagerSprinkles commented 7 months ago

My Truenas server has an intel xeon E5-1620 v4 so its an older cpu but plenty powerful.

I made the change you mentioned and it seems the cpu usage is back down to how it was before, barely noticeable. I guess 10 seconds was a little too frequent for my system. This integration is working great again now!

Also related to this update_interval, do you plan on making this configurable? Not sure the effort involved as I have not made a home assistant integration before but I feel it might be a feature someone would find useful.

Thanks again! This should be good to close out if you want.

tomaae commented 7 months ago

great. I dont currently have plans to make it configurable. 60 sec is standard, 10 is there just for development. Its fairly easy to make update interval configurable if its needed, thats not a problem.

JagerSprinkles commented 7 months ago

The 10 seconds makes sense for development. I have done similar with my projects. I don't think I need to have the update interval configurable, I was just curious. I don't need to request features I won't use.

I am going to close this out now as it looks like everything has been working fine overnight.