Skip to content

Conversation

@tatsuya6502
Copy link
Member

@tatsuya6502 tatsuya6502 commented Jan 1, 2022

This is a follow-up PR for #24.

This PR makes these caches not to initialize the LFU filter (FrequencySketch) at the cache creation time, but initialize and enable it once the cache is half full (based on the weighted size).

The size of the FrequencySketch is determined by the followings:

  • If the weigher is set, use the current number of the entries in the cache.
  • If not, use the max_capacity of the cache, which is equals to the max number of entries.

This PR also changes the max_capacity from usize to u64.

Do not initialize the LFU filter (`FrequencySketch`) at the cache creation time.
Initialize and enable it once the cache gets half full.
Ensure to use the latest entry counts when initializing the filter.
Fix some errors on calculating the entry count.
Enhance unit tests for weight-based cache management.
Remove unnecessary `pub(crate)`.
@tatsuya6502 tatsuya6502 added this to the v0.7.0 milestone Jan 1, 2022
@tatsuya6502 tatsuya6502 added the enhancement New feature or request label Jan 1, 2022
Copy link
Member Author

@tatsuya6502 tatsuya6502 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging.

@tatsuya6502 tatsuya6502 merged commit fb29073 into master Jan 1, 2022
@tatsuya6502 tatsuya6502 deleted the lazy-lfu branch January 1, 2022 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants