Skip to content

Commit deabe99

Browse files
bdracofrenck
authored andcommitted
Add guidance on dumping template information to the profiler integration (#26855)
1 parent 2110062 commit deabe99

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

source/_integrations/profiler.markdown

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The Profiler integration provides a profile which is a set of statistics that id
1616

1717
{% include integrations/config_flow.md %}
1818

19-
### Service `profiler.start`
19+
### Service {% my developer_call_service service="profiler.start" %}
2020

2121
Start the profiler for the specified number of seconds.
2222

@@ -51,7 +51,7 @@ dot callgrind.dot -Tpng -o callgrind.png
5151
gprof2dot -f pstats profile.1234567890123456.cprof | dot -Tsvg -o profile.svg
5252
```
5353

54-
### Service `profiler.memory`
54+
### Service {% my developer_call_service service="profiler.memory" %}
5555

5656
<div class='note warning'>
5757
This service is unavailable when using Python 3.11 as the underlying guppy3 library does not yet support Python 3.11.
@@ -73,7 +73,7 @@ from guppy import hpy
7373
hpy().pb()
7474
```
7575

76-
### Service `profiler.start_log_objects`
76+
### Service {% my developer_call_service service="profiler.start_log_objects" %}
7777

7878
Start logging the growth of objects in memory.
7979

@@ -83,11 +83,11 @@ Start logging the growth of objects in memory.
8383

8484
Periodically log the growth of new objects in memory. This service's primary use case is finding memory leaks. This service can be run for long periods to find slow leaks. For finding fast leaks, `profiler.start_log_object_sources` is preferred; however, it is much more CPU intensive.
8585

86-
### Service `profiler.stop_log_objects`
86+
### Service {% my developer_call_service service="profiler.stop_log_objects" %}
8787

8888
Stop logging the growth of objects in memory.
8989

90-
### Service `profiler.start_log_object_sources`
90+
### Service {% my developer_call_service service="profiler.start_log_object_sources" %}
9191

9292
Start logging the growth of objects in memory and attempt to find the source of the new objects.
9393

@@ -100,19 +100,32 @@ Periodically log the growth of new objects in memory. This service's primary use
100100

101101
This service is similar to `start_log_objects` except that it is much more CPU intensive since it will attempt to locate the source of each new object up to `max_objects` each time it logs.
102102

103-
### Service `profiler.stop_log_object_sources`
103+
### Service {% my developer_call_service service="profiler.stop_log_object_sources" %}
104104

105105
Stop logging the growth of objects with sources in memory.
106106

107-
### Service `profiler.dump_log_objects`
107+
### Service {% my developer_call_service service="profiler.dump_log_objects" %}
108108

109109
| Service data attribute | Optional | Description |
110110
| ---------------------- | -------- | ----------- |
111111
| `type` | no | The type of object to dump to the log.
112112

113113
When `start_log_objects` highlights the growth of a collection of objects in memory, this service can help investigate. The `repr` of each object that matches `type` will be logged.
114114

115-
### Service `profiler.log_thread_frames`
115+
This service is useful for investigating the state of objects in memory. For example, if your system has templates that are rendering too frequently, the below example service calls shows how to find which templates are the source of the problem:
116+
117+
```yaml
118+
service: profiler.dump_log_objects
119+
data:
120+
type: RenderInfo
121+
```
122+
```yaml
123+
service: profiler.dump_log_objects
124+
data:
125+
type: Template
126+
```
127+
128+
### Service {% my developer_call_service service="profiler.log_thread_frames" %}
116129
117130
To help discover run away threads, why the executor is overloaded, or other threading problems, the current frames for each running thread will be logged when this service is called.
118131
@@ -147,14 +160,14 @@ An example is below:
147160
sock.connect(address)
148161
```
149162
150-
### Service `profiler.log_event_loop_scheduled`
163+
### Service {% my developer_call_service service="profiler.log_event_loop_scheduled" %}
151164
152165
Log what is scheduled in the event loop. This can be helpful in tracking down integrations that do not stop listeners when Home Assistant stops or do not have sufficient locking to avoid scheduling updates before the previous update is finished.
153166
154167
Each upcoming scheduled item is logged similar to the below example:
155168
156169
`[homeassistant.components.profiler] Scheduled: <TimerHandle when=1528307.1818668307 async_track_point_in_utc_time.<locals>.run_action(<Job HassJobType.Coroutinefunction <bound method DataUpdateCoordinator._handle_refresh_interval of <homeassistant.components.screenlogic.ScreenlogicDataUpdateCoordinator object at 0x7f985d896d30>>>) at /usr/src/homeassistant/homeassistant/helpers/event.py:1175>`
157170

158-
### Service `profiler.lru_stats`
171+
### Service {% my developer_call_service service="profiler.lru_stats" %}
159172

160173
Logs statistics from [lru_cache](https://docs.python.org/3/library/functools.html#functools.lru_cache) and [lru-dict](https://pypi.org/project/lru-dict/) to help tune Home Assistant and locate memory leaks.

0 commit comments

Comments
 (0)