mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-05-28 18:43:40 +00:00
perf(interval_pool): run GC after touch-only interval updates
Touch operations create dead intervals in old fetch groups, but GC only ran when new intervals were added. Dead intervals accumulated until the next fetch with genuinely new data. Now run GC after touch-only paths and schedule a save if data changed. Impact: Reduces memory usage by cleaning up stale fetch groups promptly instead of letting dead intervals accumulate between API fetches.
This commit is contained in:
parent
ebcb9cfe77
commit
361498b7f5
1 changed files with 14 additions and 7 deletions
|
|
@ -725,13 +725,20 @@ class TibberPricesIntervalPool:
|
|||
if intervals_to_touch:
|
||||
self._touch_intervals(intervals_to_touch, fetch_time_dt)
|
||||
|
||||
if not new_intervals:
|
||||
if intervals_to_touch:
|
||||
# Run GC after touch even if no new intervals — touching creates dead
|
||||
# intervals in old fetch groups that should be cleaned up promptly.
|
||||
if intervals_to_touch and not new_intervals:
|
||||
gc_changed_data = self._gc.run_gc()
|
||||
|
||||
_LOGGER_DETAILS.debug(
|
||||
"All %d intervals already cached for home %s (touched only)",
|
||||
"All %d intervals already cached for home %s (touched only, GC ran: %s)",
|
||||
len(intervals),
|
||||
self._home_id,
|
||||
gc_changed_data,
|
||||
)
|
||||
|
||||
if (intervals_to_touch or gc_changed_data) and self._hass is not None and self._entry_id is not None:
|
||||
self._schedule_debounced_save()
|
||||
return
|
||||
|
||||
# Sort new intervals by startsAt
|
||||
|
|
|
|||
Loading…
Reference in a new issue