Commit 20cfd37
authored
Fix/various bugs found (#21)
* Add regression tests for cache policies to ensure capacity-0 behavior
- Introduced regression tests across multiple cache policies (ARC, MFU, MRU, SLRU, TwoQ) to verify that caches with a capacity of 0 correctly reject inserts and maintain expected behavior.
- Added a new integration test file for cross-policy invariants to ensure consistent handling of capacity-0 across different cache implementations.
- Updated the tests README to include information about the new invariant tests, enhancing documentation clarity.
* Implement LRU eviction method and refine cache policies
- Added `evict_lru` method to the ghost list for removing the least recently used key, enhancing eviction capabilities.
- Updated ARC and other policies to utilize the new LRU eviction method, ensuring efficient capacity management.
- Refined handling of capacity checks in various policies to prevent unnecessary evictions and improve performance.
- Adjusted tests to validate the new eviction behavior and ensure consistency across cache implementations.
* Refactor ClockRing documentation and enhance API usability
- Updated operation table in `clock_ring.rs` to use links for method references, improving clarity and navigation.
- Changed `HashMap` to `FxHashMap` in documentation for better performance context.
- Added `Clone` derive to `Entry` and `ClockRing` structs to enhance usability in concurrent scenarios.
- Modified public API methods to accept borrowed keys, allowing for more flexible key types and reducing unnecessary clones.
- Improved documentation with concise examples for `clear`, `clear_shrink`, and `approx_bytes` methods, enhancing user understanding.
* Update ClockRing documentation for improved clarity and usability
- Changed `HashMap` to `FxHashMap` in the documentation to reflect performance optimizations.
- Enhanced entry and ClockRing struct documentation to clarify key borrowing capabilities.
- Added details on lookup methods accepting borrowed keys, improving API usability.
- Updated examples and descriptions to align with recent changes in the public API.
* Add iterators to ClockRing for enhanced usability
- Introduced `Iter`, `IterMut`, `Keys`, `Values`, and `ValuesMut` iterators to `ClockRing`, allowing for flexible and efficient iteration over entries, keys, and values.
- Updated documentation to include new iterator methods and examples, improving clarity and user guidance.
- Enhanced the operation table to reflect the addition of iteration capabilities, ensuring comprehensive API coverage.
* Fix concurrency issues and enhance cache policies
- Resolved TOCTOU race conditions in `ConcurrentSlabStore` by consolidating `RwLock`s for atomicity during updates and removals.
- Fixed ARC ghost-list directory leak to maintain invariant bounds during eviction.
- Updated capacity handling in `Clock`, `ClockPro`, and `NRU` policies to reject zero capacity inserts gracefully.
- Unified `CoreCache::insert` behavior across `MRU`, `SLRU`, and `TwoQ` policies for consistency.
- Added metrics tracking for `ConcurrentWeightStore` operations.
- Introduced new `GhostList::evict_lru()` method and iterators for `ClockRing`, along with integration tests for concurrency and policy invariants.
- Updated `ClockRing` documentation with improved clarity and expanded operations table.1 parent a72fd3c commit 20cfd37
17 files changed
Lines changed: 1642 additions & 222 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
10 | 28 | | |
11 | 29 | | |
12 | 30 | | |
| |||
0 commit comments