The Cache Simulator supports multiple prefetching strategies to reduce cache miss latency.
Prefetching brings data into the cache before it is explicitly requested, hiding memory latency for predictable access patterns.
Sequential access detection and prefetching.
How it works:
- Detect sequential access patterns
- Prefetch subsequent cache lines
- Store in dedicated stream buffers
Configuration:
{
"l1": {
"prefetching": {
"enabled": true,
"type": "stream",
"distance": 4,
"bufferSize": 4
}
}
}Parameters:
| Parameter | Description | Default |
|---|---|---|
distance |
Number of blocks to prefetch ahead | 4 |
bufferSize |
Stream buffer entries | 4 |
Pattern-based prefetching for regular stride accesses.
How it works:
- Track address deltas between accesses
- Detect repeating stride patterns
- Predict and prefetch next addresses
Configuration:
{
"l1": {
"prefetching": {
"enabled": true,
"type": "stride",
"confidence": 2,
"tableSize": 256
}
}
}Parameters:
| Parameter | Description | Default |
|---|---|---|
confidence |
Required pattern matches before prefetch | 2 |
tableSize |
Stride predictor table entries | 256 |
Dynamic strategy selection based on workload.
How it works:
- Monitor prefetch accuracy
- Adjust aggressiveness based on feedback
- Switch strategies when patterns change
Configuration:
{
"l1": {
"prefetching": {
"enabled": true,
"adaptive": true,
"minAccuracy": 0.5,
"aggressiveness": "medium"
}
}
}Aggressiveness levels:
conservative: Prefetch only on high confidencemedium: Balance between coverage and accuracyaggressive: Prefetch on any pattern detection
# Enable prefetching (default settings)
./cachesim 64 32768 4 262144 8 1 4 traces/sequential.txt
# P D = Prefetch enabled, Distance 4
# Disable prefetching
./cachesim 64 32768 4 262144 8 0 0 traces/random.txtThe simulator reports prefetching metrics:
Stream Buffer Statistics:
Buffer Size: 4
Hits: 1234
Accesses: 5000
Hit Rate: 24.7%
Prefetch Statistics:
Prefetches Issued: 2500
Useful Prefetches: 1850
Accuracy: 74.0%
Coverage: 46.3%
Key metrics:
| Metric | Description |
|---|---|
| Hits | Accesses served from prefetched data |
| Accuracy | Useful prefetches / Total prefetches |
| Coverage | Prefetch hits / Total misses avoided |
- Sequential access patterns (array traversal)
- Regular stride patterns (matrix operations)
- Streaming workloads
- Random access patterns
- Small working sets
- Memory-bandwidth constrained systems
Typical improvements with prefetching:
| Access Pattern | Miss Reduction | Notes |
|---|---|---|
| Sequential | 50-80% | Best case for stream buffers |
| Strided | 30-60% | Depends on stride regularity |
| Random | 0-5% | Prefetching not effective |
| Mixed | 15-40% | Adaptive works best |
- Analyze workload first - Check access patterns before enabling
- Start conservative - Begin with small prefetch distance
- Monitor accuracy - Disable if accuracy drops below 50%
- Consider bandwidth - Aggressive prefetching uses more bandwidth
- Use adaptive mode - For workloads with varying patterns
Low prefetch accuracy:
- Reduce prefetch distance
- Switch to stride-based for irregular patterns
- Enable adaptive mode
No improvement from prefetching:
- Verify workload has predictable patterns
- Check if working set fits in cache already
- Increase cache size before tuning prefetch
Cache pollution from prefetching:
- Reduce aggressiveness
- Use dedicated prefetch buffer
- Consider no-prefetch baseline
- Configuration - Full configuration options
- Analysis Tools - Measuring prefetch effectiveness
- User Guide - Complete tutorial