Sickboy78/ioBroker.sureflap

Adapter blocks javascript / system (CPU Load 100%)

Scrounger opened this issue · 3 comments

Describe the bug
Adapter start or data refresh cause that cpu usage of javascript instance raised to 100% and blocks the whole scripts running.

It took me a long time to find the cause of the problem, as I always looked for it in a script.
However, the error is reproducible on two systems.

  1. freshly installed system without any scripts:
    keine_scripte

  2. my productive system
    prod_system

Versions:

  • Adapter version: 1.2.3
  • JS-Controller version: 5.0.17
  • Node version: 18.19.1
  • Operating system: ubuntu 22.04

I create a variante where the history data are disabled, see #52.
This reduces the load considerably and no longer leads to blocking.
However, when I look at the code, I think that there is a general problem when creating / deleting / updating the objects, because this is a lot of data and, for example, currently generates 1400 data points for me.
The data points should not be deleted and recreated every time, but updated if necessary.

Hi @Scrounger
thank you very much for the investigation and detailed analysis!
And thx for the PR, I'll have a look at it.

Could you tell me your system specs?
Because I dont have the problems on my system, but I have a quite powerfull Intel NUC with a i5-7260U with 16 GB ram.

The problem with the history is, that it can contain quite different data. For example it could be a cat going through a flap or eating from a feeder or the water dispenser being refilled. Depending on the actual event, it has a different structure with different data points. A cat movement contains pets, movements with a direction and the flap. A cat eating event contains pets, weights of the food consumed and the feeder data. And so on. So just updating the data points is not that simple.
But I'll think about a better solution.

Thx again and best regards!

I was also very surprised, especially because the load was not displayed at the js-controller, but at the javascript adapter...
Maybe this is also a problem of the js-controller that we see here. Since you are still using the "old" variants and not with async, it may also be due to this.

I also have a very powerfull system, Intel NUC 11 i5-1135G7 with 32 GB ram and only one cat flap.

Ok thanks am looking forward to the solution.

Please keep in mind that iorboker objects should be changed, deleted or created as rarely as possible. This leads to the effect we see above and also to additional write operations that are not good for sd cards, for example.

History is disabled by default with latest version 2.1.0, which should solve the problem for now.