Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAM consumption of camera entity #52

Closed
deblockt opened this issue Dec 9, 2022 · 7 comments
Closed

RAM consumption of camera entity #52

deblockt opened this issue Dec 9, 2022 · 7 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@deblockt
Copy link

deblockt commented Dec 9, 2022

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:

  • start the integration without camera ==> 250Mo used
  • start the integration with camera entity ==> 620Mo used

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)

  • Model Name [e.g. dreame.vacuum.p2028]: dreame.vacuum L10+
  • Firmware Version [e.g. 1156]:
  • Home Assistant Version: latest
  • Configuration Type [With or without map support]: with map
  • Errors or warnings shown in the HA logs (if applicable): no-error

linked with #48 and #38

@deblockt deblockt added bug Something isn't working question Further information is requested labels Dec 9, 2022
@deblockt
Copy link
Author

deblockt commented Dec 9, 2022

I can see that if I remove all "map objects" my home assistant instance take 270Mo in Memory

@Tasshack
Copy link
Owner

Tasshack commented Dec 9, 2022

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.

@deblockt
Copy link
Author

deblockt commented Dec 9, 2022

Thanks for theses explications, I will take a look on the code to try to understand it.

@Tasshack
Copy link
Owner

Tasshack commented Dec 9, 2022

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.

@Tasshack
Copy link
Owner

Tasshack commented Dec 9, 2022

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.

@Tasshack
Copy link
Owner

Tasshack commented Jan 12, 2023

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.

@Tasshack
Copy link
Owner

Tasshack commented Aug 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants