legrego / homeassistant-elasticsearch

Publish Home-Assistant events to Elasticsearch
https://legrego.github.io/homeassistant-elasticsearch/
MIT License
143 stars 38 forks source link

Cache sanitized datastream and attribute names #293

Closed strawgate closed 2 weeks ago

strawgate commented 3 weeks ago

Roughly 1/2 of processing time within the publish loop is spent sanitizing datastream names and normalizing attribute names.

These both are good candidates for caching as the values don't change and the sanitization/normalization is not dynamic

strawgate commented 2 weeks ago

If we decide that an lru is not a good idea we could just allowlist and bypass normalization for common attributes (every object includes the same core attributes like name, id, friendly name, etc)

We can likely do the same for the sensor domain.

My guess is this would remove the vast majority of calls to the normalize