Skip to content

Adds scoring and single-worst-candidate eviction - #15

Open
shubham-dce wants to merge 1 commit into
eviction-02-samplingfrom
eviction-03-scoring-and-evict
Open

Adds scoring and single-worst-candidate eviction#15
shubham-dce wants to merge 1 commit into
eviction-02-samplingfrom
eviction-03-scoring-and-evict

Conversation

@shubham-dce

Copy link
Copy Markdown
Owner

Summary

Adds scoring for sampled candidates, and evicition of a single worst candidate from those sampled candidates.

Changes

  • _scoring(candidates) scores the selected sample of candidates based on accessed_count/max(size, 1), and returns the candidate with worst(low) score. The 0 size case is handled, and returns None for an empty candidates list.
  • _evict_worst(candidates) removes the worst-scoring candidate now. Also cleans up the file associated with it, if any. Follow the same patters as existing __delitem__ method.
  • Deliberately did not use the retry=True in the transaction in the _evict_worst as retry loop has no cap on blocking time, if the lock is held by another writer. It will fight the planned graceful shutdown for the background thread (upcoming PRs).

Testing

  • Adds 6 tests, and runs successfully.
  • Complete test-suite passes successfully without any modification, test coverage is above 98%

Copy link
Copy Markdown
Owner Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants