Abstract
Machine learning algorithms have shown potential to improve prefetching performance by accurately predicting future memory accesses. Existing approaches are based on the modeling of text prediction, considering prefetching as a classification problem for sequence prediction. However, the vast and sparse memory address space leads to large vocabulary, which makes this modeling impractical. The number and order of outputs for multiple cache line prefetching are also fundamentally different from text prediction. We propose TransFetch, a novel way to model prefetching. To reduce vocabulary size, we use fine-grained address segmentation as input. To predict unordered sets of future addresses, we use delta bitmaps for multiple outputs. We apply an attention-based network to learn the mapping between input and output. Prediction experiments demonstrate that address segmentation achieves 26% - 36% higher F1-score than delta inputs and 15% - 24% higher F1-score than page & offset inputs for SPEC 2006, SPEC 2017, and GAP benchmarks. Simulation results show that TransFetch achieves 38.75% IPC improvement compared with no prefetching, outperforming the best-performing rule-based prefetcher BOP by 10.44%, and ML-based prefetcher Voyager by 6.64%.
Introduction
Modern processors are significantly faster than the memory (RAM) they rely on, a performance gap commonly referred to as the "memory wall." Prefetching—the process of predicting which data the CPU will need next and loading it into the cache ahead of time—is the primary mechanism used to hide memory latency. While traditional rule-based prefetchers excel at simple patterns, they struggle with the irregular memory access behaviors found in modern, complex workloads.
Recent research has turned to Machine Learning (ML) to handle these irregular patterns. However, applying ML to memory prefetching introduces three significant hurdles:
- Class Explosion: Memory addresses are typically 64-bit. Treating every unique address as a "word" in a vocabulary (similar to Natural Language Processing) creates millions of categories, making models too large and slow for hardware implementation.
- Sequential Bottlenecks: Most ML prefetchers rely on Recurrent Neural Networks (RNNs) or LSTMs, which process data sequentially. This is often too slow for the nanosecond-scale requirements of a CPU.
- Fixed Degree Constraints: Most prefetchers are designed to predict only the single next address. In practice, fetching multiple related blocks simultaneously (variable-degree prefetching) is often more efficient.
The TransFetch Architecture
To address these challenges, we introduce TransFetch, a novel prefetcher that reimagines memory prediction as a multi-label classification problem using an attention-based architecture.
Fine-Grained Address Segmentation (AS)
Instead of using a massive token dictionary to map addresses to IDs, TransFetch utilizes Fine-Grained Address Segmentation. The system splits a block address into several small, fixed-size segments (e.g., 6-bit chunks). This approach keeps the "vocabulary" tiny and fixed, eliminates the need for expensive lookup tables, and allows the model to perceive the internal structure of memory patterns across page boundaries.
Attention-Based Predictor
TransFetch replaces sequential LSTMs with a multi-head self-attention mechanism, borrowing from Transformer architectures. Unlike LSTMs, attention mechanisms can be highly parallelized in hardware, significantly reducing inference latency and making the model more suitable for integration into memory controllers.
Delta Bitmap Labeling and Throttling
Rather than predicting a single address, the model outputs a delta bitmap. Each bit in the bitmap represents a specific offset (delta) from the current address. If a bit is set to "1," that block is predicted for prefetching. To manage cache pollution, TransFetch employs Optimal-Threshold Confidence Throttling. The model provides a confidence score for each bit, and the system uses a mathematically optimized threshold to decide exactly how many blocks to fetch, balancing aggressiveness with accuracy.
Experimental Methodology
We evaluated TransFetch using the ChampSim cycle-accurate simulator across three industry-standard benchmark suites:
- SPEC CPU 2006 & 2017: Representing general-purpose computing workloads.
- GAP (Graph Algorithm Platform): Representing irregular, pointer-heavy memory accesses typical of social network analysis and graph processing.
Key Results
TransFetch demonstrates significant improvements in both prediction accuracy and system-wide performance:
- Accuracy Gains: Address segmentation achieved a 26%–36% higher F1-score compared to models using standard delta inputs and a 15%–24% higher F1-score than page-and-offset models.
- System Speedup: In simulations, TransFetch improved Instructions Per Cycle (IPC) by 38.75% compared to a baseline with no prefetching.
- Competitive Performance: TransFetch outperformed the best-performing rule-based prefetcher (BOP) by 10.44% and the state-of-the-art ML-based prefetcher (Voyager) by 6.64%.
- Efficiency Metrics: The model achieved an average prefetch accuracy of 88.56% with a coverage (the percentage of cache misses prevented) of 60.54%.
Conclusion and Future Work
TransFetch demonstrates that by combining fine-grained address segmentation with attention-based modeling, we can overcome the vocabulary and latency issues that have previously hindered ML-based prefetchers. While the current results are promising, future work will focus on reducing the hardware area and power consumption of on-chip Transformers and exploring online learning techniques to allow the prefetcher to adapt to program behavior in real-time.
Summary updated