1 unstable release
Uses new Rust 2024
new 0.1.0 | Mar 12, 2025 |
---|
#68 in Caching
40KB
747 lines
Breve
Breve is a cache implementation that combines lightweight machine learning with efficient eviction strategies. It uses Uno as the admission policy and S3-FIFO as the eviction policy. This project is inspired by TinyUFO (Cloudflare) and builds upon its foundation with significant improvements.
Key Features
- Lightweight Machine Learning: Utilizes the Uno algorithm for cache admission decisions, employing a simple linear regression model to predict item access value
- Efficient Eviction Strategy: Based on an improved version of S3-FIFO, optimizing cache hit rates through separated queues and access counting
- Concurrency Safety: Thread-safe implementation using atomic operations and lock-free data structures
- Memory Efficiency: Offers both compact and fast storage backends to suit different needs
Core Components
Uno Admission Policy (by PsiACE)
Uno is a lightweight machine learning algorithm designed to predict the access value of cache items. It consists of two main components:
- UnoSketch: A Count-Min Sketch based implementation for estimating item access frequency and reuse distance
- UnoLearner: A simple linear regression model that optimizes prediction accuracy through online learning
S3-FIFO Eviction Policy
S3-FIFO is an efficient cache eviction algorithm, which Breve enhances with the following improvements:
- Separates cache into small and large queues for better handling of different access patterns
- Uses access counting to optimize eviction decisions
- Supports weight-aware cache management
Why "Breve"?
There are a lot of really good caching libraries named in relation to coffee, so I chose to use Breve. Although I have been having two cappuccinos a day for the last few days.
Breve is particularly well-suited for:
- High-concurrency cache systems
- Applications with strict memory efficiency requirements
- Scenarios requiring adaptive cache strategies
License
Breve is licensed under the Apache 2.0 License. Same as TinyUFO.
Dependencies
~2.2–7MB
~42K SLoC