-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve memory management #36
Conversation
When it comes to memory management, it should be avoided that the full state of all devices is potentially kept in memory. Not caching devices at all however could introduce substantial load to the database (as a single DDI call would trigger multiple loads). Ideally they can be cached somewhere between 10s (covers single DDI request) and 10m (covers full device update process). Frameworks that allow to set a TTL are So my view on the current Manager state is
|
I'll look into |
296ab47
to
696de97
Compare
Should be good to go now.
|
I think one final step is missing: we still create one DeviceUpdateManager instance per device. This instance has no additional state - but for that reason it is also rather useless. It feels like we should be able to get rid of |
The The update manager itself is just dynamically generated and not cached, which shouldn't be an issue since every update manager uses the same device cache for |
Sorry - did not look at it properly. Why not drastically simplify this?
|
Will do. |
Done. Had to ignore line length with flake8, black should handle that for the most part. Ill push another commit to fix that. |
@tsagadar ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When working based on this branch I realized a few things
*.py
files are not yet reformatted with the new settings- Should add
.prettierignore
to match pre-commit config (open question: should prettier cover*.md
,*.yml
,*.yaml
as well?) - flake8 complains about two lines (length) that black is formatting
- I am not that excited about the consistent 4 spaces formatting: usually
*.js
,*.json
,*.yaml
uses the more compact 2 spaces. Understand that Python should have it.
Also: tests do not complete successfully on my end.
The test execution issue could be due to multiple instances of the same device being in memory (as aiocache always deserializes objects). Would it be sufficient to use the built-in
|
The following two variables could be moved into UpdateManager as static fields
|
a79076f
to
f791585
Compare
Not much can be done about these, they are logging comments, I just added an ignore inline for now.
I prefer 4 spaces in HTML for sure, and python definitely should also use 4. Not 100% on the other file types, but I think consistency across the codebase increases readability, and not like modern monitors aren't big enough to display all the data. Up to you, its a pretty easy change in the future if we decide to change it.
Fixed in latest, had to rebase onto master though.
I tested this both on my work PC (Arch Linux), and my home desktop (Windows 10), and didn't have any issues with tests. Super confused about what the issue could be...
I feel like this kindof defeats the purpose of the cache in the first place? We only want to hold on to references for ~10m, to keep gooseBit efficient. We will want to move to full caching in the future anyway I think, so no reason to not just get it over with now.
WDYM by this? Class level variables? |
That is strange. Observed the issue under macOS. Will retest (also on Ubuntu)
Agree when reconsidering this. The garbage collector likely runs too frequently which will result in a low hit rate. Caching the "default_hardware" however could be helpful to avoid one additional DB access for each loaded device.
Yes, class level variables. |
Maybe it makes sense to commit |
My bad. Did not set AIOCACHE_DISABLE=1. Best to create a poetry command that takes care of this. Can look into it. |
I don't do this cause merging it is a nightmare, but we can start. |
Removes the requirement for device managers to be stored in an in-memory dictionary, which should improve memory management. Closes #35.