Garbage collection tuning in HA #276
Replies: 2 comments 3 replies
-
@bdraco Any thoughts on this, since you seem to be the HA performance guru? My one concern would be for devices with lower RAM like Raspberry Pi that are running HA. Maybe conditioning using a larger threshold based upon what psutil returns and an "average" HA object size? |
Beta Was this translation helpful? Give feedback.
-
Python 3.14 (currently in Release Candidate stage) will add incremental garbage collection which may address any concerns around this issue (assuming HA moves to 3.14), so it seems the best approach for now is wait-and-see rather than try to manually implement. https://docs.python.org/3.14/whatsnew/3.14.html |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your core improvement
It would probably help performance to increase/manually manage python garbage collection in Home Assistant.
The ways I've been thinking of improving this are:
Current limitations
Currently, HA appears to just use the default of 700 objects for gc threshold.
Technical benefits
Better performance, less "stop the world" issues when trying to perform actions.
Additional context
The first method of just bumping the threshold is very easy.
I'm not sure the second (pausing gc during startup) may or may not be beneficial. Would need to do some benchmarking. Just bumping the threshold might be enough.
The third method might be difficult or perhaps impossible to implement, but could potentially yield less overall memory usage as well as a more responsive system.
Beta Was this translation helpful? Give feedback.
All reactions