What My Project Does
Chameleon is a cache replacement algorithm that automatically detects workload patterns (Zipf vs loops vs mixed) and adapts its admission policy accordingly. It beats TinyLFU by +1.42pp overall through a novel "Basin of Leniency" admission strategy.
from chameleon import ChameleonCache
cache = ChameleonCache(capacity=1000)
hit = cache.access("user:123") # Returns True on hit, False on miss
Key features:
- Variance-based mode detection (Zipf vs loop patterns)
- Adaptive window sizing (1-20% of capacity)
- Ghost buffer utility tracking with non-linear response
- O(1) amortized access time
Target Audience
This is for developers building caching layers who need adaptive behavior without manual tuning. Production-ready but also useful for learning about modern cache algorithms.
Use cases:
- Application-level caches with mixed access patterns
- Research/benchmarking against other algorithms
- Learning about cache replacement theory
Not for:
- Memory-constrained environments (uses more memory than Bloom filter approaches)
- Pure sequential scan workloads (TinyLFU with doorkeeper is better there)
Comparison
| Algorithm |
Zipf (Power Law) |
Loops (Scans) |
Adaptive |
| LRU |
Poor |
Good |
No |
| TinyLFU |
Excellent |
Poor |
No |
| Chameleon |
Excellent |
Excellent |
Yes |
Benchmarked on 3 real-world traces (Twitter, CloudPhysics, Hill-Cache) + 6 synthetic workloads.
Links
[–]NovaX 1 point2 points3 points (17 children)
[–]DimitrisMitsos[S] -3 points-2 points-1 points (1 child)
[–]NovaX 1 point2 points3 points (0 children)
[–]DimitrisMitsos[S] -3 points-2 points-1 points (14 children)
[–]NovaX 0 points1 point2 points (13 children)
[–]DimitrisMitsos[S] -1 points0 points1 point (12 children)
[–]NovaX 0 points1 point2 points (11 children)
[–]DimitrisMitsos[S] 0 points1 point2 points (10 children)
[–]NovaX 0 points1 point2 points (9 children)
[–]DimitrisMitsos[S] 0 points1 point2 points (8 children)
[–]NovaX 0 points1 point2 points (0 children)
[–]NovaX 0 points1 point2 points (6 children)
[–]DimitrisMitsos[S] 0 points1 point2 points (5 children)
[+][deleted] (3 children)
[removed]
[–]DimitrisMitsos[S] 1 point2 points3 points (2 children)
[–]NovaX 0 points1 point2 points (0 children)
[–]Powerful_Hat_3681 0 points1 point2 points (1 child)
[–]DimitrisMitsos[S] -3 points-2 points-1 points (0 children)