Closed jpg0 closed 4 months ago
I tried disabling the event streaming for the rules UI - this completely fixed the issue for me (I'll leave it like this for the time being as the UI is inoperable otherwise). So the performance woes appear to originate from the event streaming.
That's a good find I think.
MainUI will change the badge of the rules based on it's current state and it knows the current state through the event streaming. It seems odd though that it causes problems with rules but not Things. Surely some people have hundreds of Things. I do know that event streaming is already turned off for Settings -> Items, perhaps to address this same problem.
I wonder if event streaming for Rules and Things needs to have an option that can be enabled/disabled (perhaps under Help & About ?)) or have some sort of condition where it gets disabled automatically if you have more than say 100 of them. Pagination could be another approach to limit how many events the page needs to subscribe to and process.
I am aware that things are implemented slightly differently with items compared to rules, but I'm not sure why it's so slow. With rules it literally brings may (macbook pro m1) browser to a halt. Given that it's streaming related, it may also be a factor of how much is going on in the stream in addition to the number of rules.
Hundreds of items isn't really that huge for a page though, I'd expect that this should be able to be solved if we really want to. I agree that limits would be a reasonable quick-fix however - seeing the status of a rule is rarely something that matters to me.
I tried disabling the event streaming for the rules UI - this completely fixed the issue for me
Does the issue also disappear when only removing
I would like to pinpoint the exact problem and I suspect the problem is the .find call, which is in O(n) where n is the number of rules. If this is the cause of the problem, I will refactor the state tracking to use a separate object or map, so we should get O(1) for access to the Thing state to change it.
I do know that event streaming is already turned off for Settings -> Items, perhaps to address this same problem.
AFAIK it never has been in place there, but I can confirm that event streaming for Items causes real performance issues, I have tested this some time ago.
Given that it's streaming related, it may also be a factor of how much is going on in the stream in addition to the number of rules.
I suspect this is the reason the event streaming becomes an issue. For the Things page, there is likely not going on much in the stream, Thing states change not really often.
But for rules, there is likely a lot of status changes going on, which makes the issue occur.
@jpg0 I went ahead and opened #2623. Can you please test https://github.com/openhab/openhab-webui/pull/2623#issuecomment-2186656874?
The problem
I have a large number of rules (currently 697) and the rules list in the main UI is becoming unusable. It fails entirely on phones, and repeatedly hangs when scrolling on a (fast) laptop. The items list (which has more elements in it) is fine.
Expected behavior
Rules list behaves the same way as items list.
Steps to reproduce
Your environment
Browser console
Browser network traffic
Additional information