Skip to content
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

Support the plain LRU policy #390

Merged
merged 8 commits into from
Jan 29, 2024
Merged

Support the plain LRU policy #390

merged 8 commits into from
Jan 29, 2024

Conversation

tatsuya6502
Copy link
Member

@tatsuya6502 tatsuya6502 commented Jan 27, 2024

Fixes #388. (CC: @PhotonQuantum)

This PR does the followings:

  • Adds a support for the plain LRU eviction policy.
  • Adds a new method eviction_policy to the CacheBuilder to choose either the EvictionPolicy::tiny_lfu() or the EvictionPolicy::lru() at the cache creation time.

The TinyLFU policy will remain the default until we implement the Window TinyLFU with hill climbing.

@tatsuya6502 tatsuya6502 self-assigned this Jan 28, 2024
@tatsuya6502 tatsuya6502 added the enhancement New feature or request label Jan 28, 2024
@tatsuya6502 tatsuya6502 added this to the v0.12.5 milestone Jan 28, 2024
@tatsuya6502
Copy link
Member Author

I ran some experiments with an updated Moka driver for the Caffeine Simulator:

I confirmed that the both the LRU and TinyLFU policies of Moka are working as expected. Their hit rates are comparable to the simulation results of the LRU and TinyLFU policies respectively.

ARC S3 trace

arc-s3-hit-rate

Policy 100,000 200,000 300,000 400,000 500,000 600,000 700,000 800,000
opt.Clairvoyant 25.42 39.79 50.92 59.96 67.09 72.97 77.57 81.27
sketch.WindowTinyLfu (1%) 12.18 23.38 33.85 43.00 51.36 59.27 65.43 70.62
linked.Lru_TinyLfu 10.63 22.89 33.96 43.18 51.50 59.41 65.58 70.91
product.Moka (TinyLFU) 10.44 22.62 33.10 42.47 50.87 58.44 64.87 70.32
linked.Lru 2.33 4.63 7.59 12.04 22.77 34.63 46.04 56.60
product.Moka (LRU) 2.33 4.63 7.59 12.04 22.77 34.63 46.04 56.60

Corda vault service large trace

corda-large-hit-rate

Policy 200,000 400,000 600,000 800,000 1,000,000 1,200,000 1,400,000 1,600,000
opt.Clairvoyant 33.33 33.33 33.33 33.33 33.33 33.33 33.33 33.33
sketch.WindowTinyLfu (1%) 33.33 33.33 33.33 33.33 33.33 33.33 33.33 33.33
linked.Lru_TinyLfu 5.43 10.70 16.03 21.37 26.71 32.05 33.33 33.33
product.Moka (TinyLFU) 8.22 16.14 24.11 31.94 32.02 33.33 33.33 33.33
linked.Lru 33.33 33.33 33.33 33.33 33.33 33.33 33.33 33.33
product.Moka (LRU) 33.33 33.33 33.33 33.33 33.33 33.33 33.33 33.33

- Add the documentation for `EvictionPolicy`, etc.
- Change the `EvictionPolicy` from an enum to a struct, so that we can add more
  private fields in the future without breaking the API.
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 b5560df into main Jan 29, 2024
39 checks passed
@tatsuya6502 tatsuya6502 deleted the lru-policy branch January 29, 2024 01:27
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.

1 participant