-
Notifications
You must be signed in to change notification settings - Fork 463
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
Feature/disable caching #410
base: develop
Are you sure you want to change the base?
Conversation
@@ -22,6 +22,11 @@ | |||
from typing import Dict, Type, Union, Any | |||
from urllib import parse, request | |||
|
|||
import volatility | |||
|
|||
if "--live" in sys.argv: |
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.
Hmm, this doesn't seem right. Why isn't this handled by the argparse logic below the --live option?
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.
So I concur, it's thoroughly ugly, but unfortunately the chain of imports (of volatility.framework
upwards) would import and therefore wrap all the calls before we've set the flag. So we've got two options:
- for every read check whether we're allowed to use the cache, and then use it or not
- wrap everything early with a wrapper that chooses whether to cache or not
From an efficiency perspective, the second option is better (I haven't timed to see how much, and chances are it's a couple lookups and an if, so should be pretty fast, but given our runs regularly do hundreds of thousands of reads, I went with the slight ugliness in the CLI to set the flag early enough. I might look into a way so that change the variable late will throw an exception (so that UI developers know they need to set it really early, I'm just not sure how I'd go about making a variable read-only after a certain point...
Anyway, that's why it needs to be read out of sys.argv so early. Once the parser's run, we've already imported everything to be able to enumerate it properly.
What if we tried something more localized to caching, like this? https://github.com/volatilityfoundation/volatility3/tree/feature/disable-caching-try2 |
That won't trip in time (and you can add an exception in to show that changing the flag would have no effect). The wrapping and therefore that if statement are evaluated as the files are imported. By the time you've reached there, they're all wrapped already. You'd need to write your own |
Another option may be to do through and explicitly unwrap all wrapped objects (or maybe set their cache size to 0?), but that would be monkeying deep inside of python and probably make it difficult to distinguish if there were some values we wanted cached and others we didn't... |
We can discuss it today. The exception trips for me, so I am missing something. |
Yeah, no problem. Adding the exception in after the if statement in |
Following a discussion, we've considered that performance (particularly for the common case) is important, but this approach is a bit complex/ugly so we're going to defer making this change for a bit. |
This feature adds support for (very early) deciding as to whether caching of layer reads should be enabled throughout the codebase. It's not ideal because the main toggle doesn't live in volatility.frameworks.constants like it should, because volatility.framework imports other parts of the framework that already need to know whether the caching is enabled or not. To avoid this issue, the toggle lives just in
volatility
.