Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OH3] Defining Rules in Main UI increases CPU Load #1877

Closed
gdolfen opened this issue Nov 30, 2020 · 5 comments · Fixed by #2057
Closed

[OH3] Defining Rules in Main UI increases CPU Load #1877

gdolfen opened this issue Nov 30, 2020 · 5 comments · Fixed by #2057

Comments

@gdolfen
Copy link

gdolfen commented Nov 30, 2020

I have a problem with high cpu usage in M2 and M3.
I figuerd out that the reason are rules which are configure over main ui.
I started with 4 rules in a *.rules file with a cpu usage of 1%. In main ui they always stay on "IDLE" after migration them to main ui by copy the generated code by the code view everything was fine, but the logs was full with ERRORs "No pre-parsed script found for e3dc-2". So I deleted the line "// context: e3dc-2" from the code and the log disappears, but the cpu was increased up to 5% per rule and the state stays always on "RUNNING".
Here is my rule code:

triggers:
  - id: "0"
    configuration:
      itemName: E3DC_Extern
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: script
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |
        // context: e3dc-2
        var Number negativeValue = E3DC_Extern.state as Number
        var Number positiveValue = negativeValue * -1
        E3DC_String3.postUpdate(positiveValue)
    type: script.ScriptAction

It seemed that the rule is parsed every time, because every 5 seconds (5 seconds update period of item E3DC_Extern) I got the log error. Maybe preparsing the rule after saving it in main ui makes the trick.

@Boby71
Copy link

Boby71 commented Dec 28, 2020

+1; same for me on OH3.0.0 stable:
After defining many DSL rules on my system, I run into errors like "java.lang.OutOfMemoryError: Java heap space" which leaves the system completely unresponsive after a while.

It seems to happen when the rule(s) are triggered often, by a constantly changing value (e.g. a temp sensor). The rules seem to take too long to run (e.g. a few seconds for a simple postUpdate) and when there are enough rules running and new ones started upon, the system runs out of memory. So there is a bug in DSL rules processing when they have been defined via the GUI.

@JohannesPtaszyk
Copy link

JohannesPtaszyk commented Dec 29, 2020

I got this issue as well. My hue dimmer switch state is changed almost instantly, but the rule for it takes like 10 seconds to execute.
My raspberry pi goes from 1% usage to 28% upon execution and it takes 10 seconds.
1 Core goes up to 100%

@JohannesPtaszyk
Copy link

I moved my setup to a Raspberry Pi 4 4GB and now everything is working fine.

@kaikreuzer
Copy link
Member

Thanks for the report. I have created #2057 for it, it would be great if you could test a snapshot, once that PR is merged and available in the distro!

@gdolfen
Copy link
Author

gdolfen commented Jan 5, 2021

@kaikreuzer: I testet your change with the latest snapshot build an the problem is gone. Thanks a lot for your fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants