Closed FaserF closed 3 years ago
HA OS seems to cache way too much stuff
Yellow is probably mostly page cache, and is very important to make reads faster. Essentially Linux tries to keep files (code or data) in memory as much as possible to speed up subsequent reads.
Usually things only get swapped out when its really not used for a long time (but needs to be in memory).
Imagine Home Assistant reads data (e.g. from database) every time you open your dashboard. You want your Raspberry Pi to keep that in memory. Whereas some program code from a service started in the background which is used very seldom, should be written out to swap to not take up valuable memory.
HAOS is built on Linux, which in terms has a very sophisticated algorithms to manage memory. We don't tune memory management special, and it has served well so far.
Btw: In HAOS, swap is also in memory, but compressed using zram. This is done to avoid wearing out SD cards. One might ask why use swap then even? Its a trade off: Compressed swap allows to store more in memory at the cost of CPU time. We basically trade more memory with some CPU cycles.
Is there anything to improve this? Is this a bug or a "feature"?
There are tunables in Linux, and in theory you can minimize caching. But your system is pretty much guaranteed to feel slower. In the end just "tune" for the sake of moving a bar is not helpful. You need to dig into why your Raspberry Pi 4 feels slow exactly. I don't have a straight forward recipe how to do that. Monitoring CPU/memory load, and trying different configurations might help to find what improves the situation.
I am closing this issue as its not really an issue.
Wow, thank you so much for such a detailed answer!
Hardware Environment
Home Assistant OS release:
Journal logs:
Kernel logs:
Description of problem:
HA OS seems to cache way too much stuff (yellow bar) and then swaps out much stuff. This makes my raspberry pi 4 feel very slow.
A friend of mine (Raspberry Pi 4) has the same issue.
Is there anything to improve this? Is this a bug or a "feature"?