TL;DR
CachePerf is a unified cache miss profiling tool that automatically classifies both the type (capacity, conflict, or coherency) and the origin (application code vs. memory allocator) of cache misses. By combining coarse-grained hardware performance counters with fine-grained hardware breakpoints, it achieves high diagnostic accuracy with an average performance overhead of just 14%.
What Problem Does This Paper Address?
Cache misses are a notorious bottleneck in modern high-performance computing, but fixing them requires knowing exactly why and where they happen. Cache misses fall into distinct categories—compulsory, capacity, conflict, and coherency (true or false sharing)—and each demands a completely different optimization strategy (e.g., loop tiling vs. data structure padding). Furthermore, misses don't just originate from poorly written application code; they are frequently introduced by the memory allocator's layout choices.
Existing diagnostic tools force developers into a corner. Simulation-based profilers (like Valgrind's Cachegrind) provide deep insights but introduce prohibitive 100x performance overheads, making them unusable for production workloads. Conversely, existing sampling-based tools are highly siloed, typically detecting only one specific type of miss while completely ignoring allocator-induced issues. CachePerf bridges this gap by providing a low-overhead, comprehensive, and unified classification framework.
Methods
CachePerf introduces a novel hybrid hardware sampling scheme that balances low runtime overhead with precise, instruction-level history tracking. Its architecture relies on four interconnected modules:
- Access Sampler & Miss Ratio Checker: CachePerf leverages the processor's built-in Performance Monitoring Unit (PMU) to perform coarse-grained address sampling. To avoid wasting resources on minor issues, a windowing mechanism calculates the real-time cache miss ratio and filters out sporadic or low-frequency misses.
- Breakpoint Handler: When the sampler flags a "susceptible instruction" with a high miss rate, CachePerf dynamically installs a hardware breakpoint on it. This triggers fine-grained sampling, capturing a short, precise history of consecutive memory accesses to expose the exact access pattern.
- Allocation Intercepter & Object Store: The tool intercepts memory management functions (
malloc,free) and maintains an optimized, three-level data store (comprising a Page Table, Chunk Table, and Sorted Huge Objects List) to rapidly map raw memory addresses back to specific heap or global objects. - Miss Classifier: By combining the fine-grained access patterns with object allocation data, the classifier applies a rule-based algorithm to determine the exact type of miss and pinpoint whether the root cause is the application or the allocator.
Datasets
The authors evaluated CachePerf across a diverse suite of benchmarks and real-world applications containing known and unknown cache performance anomalies:
- PARSEC-2.0 Benchmark Suite: 13 general-purpose multithreaded applications (e.g.,
raytrace,canneal,streamcluster). - Hoard Stress Tests: Microbenchmarks (
cache-scratchandcache-thrash) specifically designed to evaluate allocator-induced false sharing. - Phoenix Applications:
histogramandlinear_regression, used to evaluate application-level coherence misses. - CCProf Benchmarks: A collection of applications (
ADI,HimenoBMT,Kripke,MKL-FFT,NW) known to suffer from severe conflict misses. - ArrayTool Benchmarks:
IRSandSRAD, utilized to evaluate capacity misses. - Memory Allocators: Evaluated using both the default
Glibc-2.28allocator and Google's high-performanceTCMalloc-4.5.3.
Key Insights and Ideas
- Access Patterns Trump Miss Distribution: Prior state-of-the-art tools assumed conflict misses could be identified simply if a subgroup of cache sets experienced a disproportionately high volume of misses. The authors demonstrate that this assumption is flawed. In applications like
Kripke, cache misses are perfectly uniform across all sets, yet they are strictly conflict misses driven by sequential thrashing patterns. - Exposing the Allocator Blindspot: Memory allocators frequently cause severe cache degradation by scattering independent objects across addresses that map to the identical cache set (causing conflict misses) or placing concurrent objects from different threads onto the same cache line (causing false sharing). CachePerf is the first tool to explicitly isolate and report these allocator-induced issues.
- The Power of Hybrid Sampling: Coarse-grained PMU sampling acts as an efficient hardware filter, ensuring that expensive hardware breakpoints are only deployed on a tiny fraction of instructions. This keeps performance overhead minimal while retaining exact address-level history when it matters most.
Key Results
- Minimal Overhead: On average, CachePerf introduces a performance overhead of only 14% (compared to 5.3× for CCProf and 80% for Feather) and a modest 19% memory overhead for large-footprint applications.
- Bug Detection: The tool successfully identified all previously known cache bugs and uncovered 9 entirely new bugs across well-studied benchmarks.
- Massive Performance Gains: Remedying the bugs reported by CachePerf yielded dramatic application speedups ranging from 3% to a staggering 3788% (achieved by fixing allocator-induced false sharing in
cache-thrash). Simply switching two nested loops inSRADbased on CachePerf's report resulted in a 748% speedup.
Limitations and Future Work
- Hardware Skids: Due to physical limitations in processor PMUs, "skids" can occur where the hardware fails to pinpoint the exact instruction causing a miss, occasionally offshooting by one or two instructions. This led to a single misclassification in the
ADIbenchmark. - Reporting Phase Bottlenecks: For applications that touch a massive number of unique cache sets and heap objects (like
MKL-FFT), CachePerf's reporting phase slows down due to expensive, synchronousaddr2linebinary analysis calls. The authors plan to move this phase entirely offline or introduce faster heuristics. - High Allocation Rates: In programs with extreme allocation frequencies (e.g.,
canneal, which performs 1.3 million allocations per second), tracking object lifetimes in the Object Store still introduces noticeable overhead.
Summary updated