home-assistant / home-assistant/core

Statistics takes longer than 1.111 seconds at startup

Open
#110,433 8 comments 0 reactions 0 assignees View on GitHub
integration: statistics no-stale
Dominant language
Python
Stars
90.5k
Forks
38.6k
Avg merge
1d 2h
Merged PRs (30d)
597

Description

### The problem

running debugpy reveals several remarkable timings during setup.
writing this up per request.

### What version of Home Assistant Core has the issue?

2024.2.x

### What was the last working version of Home Assistant Core?

_No response_

### What type of installation are you running?

Home Assistant OS

### Integration causing the issue

statistics

### Link to integration documentation on our website

https://www.home-assistant.io/integrations/statistics/

### Diagnostics information

_No response_

### Example YAML snippet

_No response_

### Anything in the logs that might be useful for us?

```txt
2024-02-12 18:06:06.833 WARNING (MainThread) [asyncio] Executing result=None created at /usr/src/homeassistant/homeassistant/core.py:633> took 1.111 seconds
```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by profiling the StatisticsSensor._initialize_from_database() entry point named in homeassistant/components/statistics/sensor.py:534, using the debugpy timing evidence in the issue. Trace the startup work that exceeds 1.111 seconds and establish a focused regression check; done means the statistics initialization no longer causes the reported startup delay.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.