Sketching the Path to Efficiency: Lightweight Learned Cache Replacement

Rana Shahout, Roy FriedmanOPODIS 2023 · OpenReview

TL;DR

This paper introduces ALPS, a novel cache management framework that uses lightweight machine learning to dynamically select the best heuristic caching policy for upcoming data access patterns. By leveraging space-efficient sketches to extract features instead of per-item data, ALPS achieves superior hit ratios with significantly reduced memory overhead compared to existing ML-based approaches.

What Problem Does This Paper Address?

Caches are crucial for improving system performance by storing frequently accessed data closer to users. The effectiveness of a cache heavily relies on its management policy, which decides which data items to keep and which to evict. Traditional heuristic policies (like LRU or LFU) are often inconsistent, performing well on some access patterns but poorly on others. While machine learning (ML) offers the potential for more adaptive and accurate predictions, existing ML-based cache management solutions suffer from substantial memory overhead. They typically require storing per-item information and invoking complex models on every access, which contradicts the goal of minimizing a cache's resource footprint. This paper aims to bridge this gap by developing an ML-driven cache management policy that is both highly effective and memory-efficient.

Methods

The core innovation of ALPS is its "frame-based" approach combined with "sketches." Instead of processing individual cache accesses, ALPS divides the data access stream into fixed-size "frames." At the end of each frame, it uses an ML model to predict the most suitable heuristic caching policy for the next frame.

The key to ALPS's efficiency lies in how it gathers information for the ML model:

  • Space-Efficient Sketches: Instead of storing detailed per-item data, ALPS uses several space-efficient data structures called "sketches" (including Space Saving, HyperLogLog, Count-Min Sketch, and a novel "ISketch" for inter-arrival times) to summarize the access patterns within a frame. These sketches capture statistical indicators like item frequencies, unique item counts, and recency information without storing individual item details.
  • Feature Extraction: The statistical summaries from these sketches are then used as input features for a lightweight neural network (NN) ML submodel.
  • Frame-Based Prediction: The NN predicts the optimal heuristic policy (e.g., LRU, LFU, ARC) for the upcoming frame. This prediction is made only once per frame, significantly reducing computational overhead compared to per-access ML.
  • Dynamic Policy Switching: Based on the ML model's prediction, ALPS dynamically switches to the recommended heuristic policy for the next frame.

The novel ISketch is specifically designed to track inter-arrival times of items with low inter-arrival values, providing a compact way to estimate recency.

Datasets

The authors evaluated ALPS using real-world workloads from various domains, including:

  • P1-P14, Mergep: 14 traces from Windows NT workstations capturing disk operations, totaling approximately 491 million accesses.
  • Gradle: A trace from the Gradle build cache project, representing about 2 million accesses.
  • Scarab: A trace from product recommendation lookups for e-commerce sites, containing approximately 28 million accesses.
  • Wikipedia: A trace representing 10% of Wikipedia traffic, about 12 million accesses.

These traces were meticulously partitioned into subsets for training, validation, and testing to prevent overfitting.

Key Insights and Ideas

  • Frame-based ML is more efficient: Processing data in frames rather than individual accesses drastically reduces the computational burden of ML models in caching.
  • Sketches are powerful feature extractors: Space-efficient sketches can capture essential statistical properties of access patterns, providing effective features for ML models without the memory cost of per-item storage.
  • Combining heuristics with ML is a winning strategy: ALPS demonstrates that ML can intelligently select and orchestrate existing heuristic policies, achieving better performance than any single heuristic alone.
  • Recency and frequency are key, but their interplay is dynamic: The effectiveness of different heuristic policies varies, and ML can adapt to these dynamic shifts by analyzing sketch-derived features.
  • Lightweight ML is achievable: By focusing on frame-level predictions and sketch-based features, ML can be integrated into resource-constrained caching systems.

Key Results

  • Superior Hit Ratio: ALPS consistently achieved the highest hit ratio across various workloads and cache sizes, outperforming popular heuristic policies (LFU, LRU, Hyperbolic, ARC, W-TinyLFU) and state-of-the-art ML-based policies (LRB, CACHEUS). For instance, ALPS improved hit ratios by up to 20% over LRU and 31% over Hyperbolic.
  • Drastically Reduced Memory Overhead: ALPS's memory overhead was orders of magnitude lower than LRB and CACHEUS. This is because ALPS's overhead is dominated by sketches, which are constant in size relative to the cache, whereas LRB and CACHEUS have memory requirements that scale with cache size and item data.
  • Low Inference Overhead: The ML inference is performed only once per frame, resulting in low computational costs. For a frame size of 10,000 items, inference time was around 0.3 milliseconds.

Limitations and Future Work

  • Frame Size Optimization: The paper notes that determining the optimal frame size is critical and can be viewed as a hyperparameter or a model parameter. While they set a default of 10 times the cache size, further research could explore more adaptive frame size selection.
  • Expanding Training Set: The authors suggest that training ALPS with a wider variety of heuristic-based caching algorithms could further enhance its performance.
  • Advanced Features: Future work could explore incorporating additional features or more sophisticated ML models.
  • Weighted Items and Optimal Cache Sizing: The authors plan to extend ALPS to support weighted items and predict the optimal cache size.

Summary updated

Abstract

Cache management policies are responsible for selecting the items that should be kept in the cache, and are therefore a fundamental design choice for obtaining an effective caching solution. Heuristic approaches have been used to identify access patterns that affect cache management decisions. However, their behavior is inconsistent, as they can perform well for certain access patterns and poorly for others. Given machine learning’s (ML) remarkable achievements in predicting diverse problems, ML techniques can be applied to create a cache management policy. Yet a significant challenge arises from the memory overhead associated with ML components. These components retain per item information and must be invoked on each access, contradicting the goal of minimizing the cache’s resource signature. In this work, we propose ALPS, a light-weight cache management policy that takes into account the cost of the ML component. ALPS combines ML with traditional heuristic-based approaches and facilitates learning by identifying several statistical features derived from space-efficient sketches. ALPS’s ML process derives its features from these sketches, resulting in a lightweight and highly effective meta-policy for cache management. We evaluate our approach over real-world workloads run against five popular heuristic cache management policies as well as a state-of-the-art ML-based policy. In our experiments, ALPS always obtained the best hit ratio. Specifically, ALPS improves the hit ratio compared to LRU by up to 20%, Hyperbolic by up to 31%, ARC by up to 9% and W-TinyLFU by up to 26% on various real-world workloads. Its resource requirements are orders of magnitude lower than previous ML-based approaches.
BibTeX
@inproceedings{shahout2023sketching,
  author = {Rana Shahout and Roy Friedman},
  title = {{Sketching the Path to Efficiency: Lightweight Learned Cache Replacement}},
  booktitle = {OPODIS},
  year = {2023},
  url = {https://openreview.net/forum?id=d63mnVmC8O},
}
Figure