-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Improve performance for state update handling #3635
Conversation
Signed-off-by: Jan N. Klug <[email protected]>
Signed-off-by: Jan N. Klug <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvements, tested on my raspberry pi with > 50 item updates/s which are handled with ease now. Before it was struggling with 30 updates/s.
Signed-off-by: Jan N. Klug <[email protected]>
Signed-off-by: Jan N. Klug <[email protected]>
In my TODO list for the weekend to review this PR. |
This code is probably correct even if I don't understand why it is better to use an event subscriber rather than implementing a @J-N-K : I assume you checked that live update in BasicUI and Android app is still working as expected after your changes ? |
For me everything on BasicUI and Android app still works as before and I have quite some elements in it. |
@kaikreuzer and all @openhab/core-maintainers : as it is said that performance are greatly improved (for users considering OH as a real-time system), I believe this PR should be considered. As it impacts a sensible part of sitemap UIs, I would suggest to not wait for the last OH4 minute to merge it but rather include it in coming milestone to have few weeks feedback form users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. My assumption is that the multi-threaded eventhandler brings the performance (well it actually shows that the event subscribers are not implemented well, since they are expected to return immediately...).
I do not see why moving to events for the page listeners is relevant here, but I am fine with that change as well. It is the riskier part wrt potential regressions, but I cannot think of a situation where this might be an issue. The only cases that would now differ in behavior are the ones where an item state changes without an event being created; this might only be the case at the system startup, but at that moment we do not care too much about the page update notifications either.
TL;DR: Lgtm, let's merge and have 2 more milestones for testing before GA.
I believe the title of the PR could be enhanced to mention that it concerns sitemap UIs. |
* Improve threading in EventHandler * refactor pagechangelistener to event * One executor per subscriber type, not per subscriber Signed-off-by: Jan N. Klug <[email protected]> GitOrigin-RevId: a656073
Fixes #3620
There are two improvements in this PR:
EventHandler
now uses a "one-thread-per-subscriber` policy. This prevents single "slow" consumers from blocking others but still preserves event order.PageChangeListener
and theSitemapResource
have been refactored to use events instead implementingStateChangeListener
.