-
Notifications
You must be signed in to change notification settings - Fork 171
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
Implement cache eviction #610
Conversation
Introduce a `CacheLimit` argument for the `DiskDataCache` to configure the eviction policy. If a limit is set, the cache will track usage of the stored blocks. On put, it will check if the limit has been exceeded and start removing the least recently used blocks if required. Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
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.
Nice! just a few minor comments
Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
127a27d
to
b07256c
Compare
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.
There's two comments but I don't want to block on them. LGTM.
Ok(stats) if stats.total_space() == 0 => { | ||
warn!("unable to determine available space"); | ||
return false; | ||
} |
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.
Thinking about this a little more, maybe we should switch the cache limit to Unbounded
when we encounter this... otherwise this is a lot of WARN
logging 😄
Though that requires us to switch to &mut self
or something. Maybe let's switch to unbounded if we notice that we can't determine total space?
(I'm happy for this to be follow-up, we're not targeting filesystems that lie about fsstat.)
Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
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.
nice, thanks for handling the not enough space case here
Description of change
Introduce a
CacheLimit
argument for theDiskDataCache
to configure the eviction policy. If a limit is set, the cache will track usage of the stored blocks. On put, it will check if the limit has been exceeded and start removing the least recently used blocks if required.Relevant issues: #255
Does this change impact existing behavior?
No.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).