Repository navigation
Add passive adaptive entity state throttling on slow devices - #56421
MindFreeze wants to merge 1 commit into
Conversation
|
👋 Hi! Thanks for contributing to Home Assistant. This is your PR dashboard which flags anything you need to address before your PR can be reviewed. Once everything is green, you can press the 'Ready for review' button at the bottom of the page to notify reviewers to take a look. More information about this dashboardThis dashboard automatically updates on every change to this PR and reevaluates the rules as you go. Until everything has been addressed, the bot will keep the PR in draft. Skip a check that doesn't applyIf you think a check doesn't apply to your PR (or the rule is bugged), comment Bot commandsReply with
Checks✨ Everything's in order! 1 check passed (2 skipped)
|
fa8bd45 to
5cc5f64
Compare
|
I'm not sure the measuring is worth it/needed, could we not throttle it always for every device with a sane 100-250ms value? That would make it a lot simpler. We could even split the subscription in 2, 1 throttled one, that contains all the entities, and 1 unthrottled one, that contains the entities that are used explicitly? That makes sure that built-in cards are always updated quick, and custom cards that don't adapt will keep work, but a bit throttled. |
Breaking change
Proposed change
Wires up
throttleMsandflushEntityStatesfromhome-assistant/home-assistant-js-websocket#824using passive, cross-browser self-measurement (EntityStateThrottler):MessageChannel+rAF → MessageChannelprobe; zero timers when idle, ~0.003–0.018 ms overhead per publish) and scales the throttle interval up to 1,000 ms to keep state updates within a ~12% main-thread budget. Fast devices on light dashboards stay at0 ms(per-frame microtask batching).hass.callService()drops the throttle interval to0 msfor 2 s so toggles and controls still update immediately.Infinitywhiledocument.hidden(whensuspendWhenHiddenis enabled) and flushes immediately viaflushEntityStates(conn)on visibility return (visibilitychange+whenDocumentVisible).Depends on home-assistant/home-assistant-js-websocket#824. Needs a release of
home-assistant-js-websocketand a version bump here before it can be merged (typecheck/build fail until then).Benchmarks (Chromium 158, 5,000 entities, busy Lovelace dashboard, 30 WS frames/sec × 15 s)
throttleMs: 0)Infinity) → Resume flushthrottleMs: 0)Screenshots
Type of change
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
To help with the load of incoming pull requests: