-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: Replace SystemStateReader.read() with lru_cache #105
Conversation
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.
I like where this is going! Just dropping a few hints on how to cleanup things
In preparation for LRU caching, don't make the reader store the variables itself. Instead, the functions return the read state directly. The now defunct read() function is removed separately
The FunctionCommand was required to reset the reader, which is not necessary anymore.
These provides are not necessary for dependecy resolving. But upcoming caching will reuse the provides and therefore require consistent use of it.
9a4806a
to
d9b587b
Compare
Add an LRU cache to the state_reader so state is only reread when an actual changing command has been executed. After command execution the cache of the relevant types is cleared.
d9b587b
to
2542fdb
Compare
BTW. I did a very quick check to see if the tests are faster....
But the tests are still requiring internet (the ubuntu keyservers AFAIU) and I only let it run a single time. But if the tests themselves only take half the time, I can imagine a great speed up for complex setups. We'll see... |
Mirrors are updated ad-hoc. No dependency-management is required. Therefore no Command is generated and the `mirror` dependency-type doesn't exist.
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.
Thanks!!!!
Removes the very time intensive
SystemStateReader.read()
function and use functions that directly return the variables.Solve the caching Problem with
lru_cache
, which is cleared with...clear_cache()
whenever a respectiveCommand
is run.Since the
Command
already has aprovides
function withknown_dependency_types
which pretty much exactly resembles the state variables that should be cached, I wrote a smallCommand.clear_caches()
function which clears caches whenever a Command has been run.I added some
provides
definitions so that it should work consistently with the cache resetting.I also split it up into various "easier to understand" feature-separate commits - they should even run through the tests individually :)
You can also read the commit notes to follow my thought process.
FWIW I don't really understand the tests all too well and am not 100% sure I didn't accidentally "break" a test. I'm also not sure if more tests would be necessary to properly test the caching... But it looks very much like my changes are correct.