Closed deblockt closed 11 months ago
I can see that if I remove all "map objects" my home assistant instance take 270Mo in Memory
Since python is very slow at rendering the map images, i have added a layer caching mechanism for rendering only the modified objects on the map. The cost of caching layers is more ram usage but without the cache it would be using too much cpu instead and cpu is more precious resource than memory. Even if you will be able to reduce the ram usage and run it on the rpi, you will be still waiting about 5 to 10 seconds for rendering a single frame and that is not acceptable. Solution to this problem is using javascipt for rendering the map images but i have to rewrite the entire renderer in js and i don't have time for that right now.
Thanks for theses explications, I will take a look on the code to try to understand it.
My specialty is c++ and this is my first python project (and probably the last) because of that there are room for improvements in the project. Renderer is mostly isolated from the rest of the project (unlike xiaomi map extractor) so please feel free to make suggestions for runing it without too much resource. I also think this is an ARM specific issue because the component does not use that much memory on my x64 system.
Also all map resources like robot image and room icons are cached on the memory too for preventing to load them everytime the map changes which adds a lot of render time otherwise.
I am closing this issue since it can be solved by adding some swap memory on linux.
I will release a custom card that renders the map on frontend to solve this issue completely.
I have added a new option in the entity configuration for rendering the map half size and it lowers memory consumption enough to make the integration work on an 1GB RPI3. This option also disables some map objects like mop path for saving extra ram.
https://github.com/Tasshack/dreame-vacuum/releases/tag/v2.0.0b6
Describe the bug
I tried to start to use this integration on a RPI3. I can't due to RAM consumption.
To Reproduce
Start this integration on a raspberry on a docker. Using docker I can see that:
Expected behavior
The camera entity should not take more that 300Mo to work
After some code analysis I can see that this RAM consumption come from call to
self._renderer.render_map(map_data, robot_status)
performed on 'camera.py' file at line 301.Additional Information (please complete the following information)
linked with https://github.com/Tasshack/dreame-vacuum/issues/48 and https://github.com/Tasshack/dreame-vacuum/issues/38