home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.03k stars 28.28k forks source link

Refactor entity_platform polling to avoid double time fetch #116877

Closed bdraco closed 1 week ago

bdraco commented 1 week ago

Proposed change

Replace async_track_time_interval with loop.call_later to avoid the useless time fetch and datetime object construction every time the listener fired since we always throw it away. Fetching time is a lot more expensive on some aarch64 system (ie Home Assistant Blue) because they cannot use VDSO due to arm errata.

In most cases, this is the second most frequent call listener after the update coordinator which already uses a similar scheduling design to avoid this problem.

Type of change

Additional information

Checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

To help with the load of incoming pull requests: