ZRay: Portable Compiler-Assisted Memory Traffic Characterization
Abstract
As memory systems become more heterogeneous, performance tuning increasingly depends on answering granular questions: Which code regions of an application generate memory traffic? On which threads? At what rate? Existing profilers force a tradeoff between portability, attribution, and overhead. PMU-based tools expose hardware behavior but depend on platform support and may be unavailable or restricted; function profilers are too coarse to isolate memory-intensive kernels; and detailed binary instrumentation is often too slow or ISA-specific for realistic workloads.This paper presents ZRay, a compiler-based approach to region-level memory characterization. ZRay’s key idea is to separate what can be known statically from what must be counted dynamically. An LLVM IR pass summarizes the memory-relevant instruction mix of developer-marked regions of source code, while lightweight sampled counters recover dynamic execution counts and timing. This static/dynamic split avoids per-instruction runtime instrumentation, does not require hardware PMUs, and still supports optional PMU snapshots when available.This approach keeps runtime overhead low while remaining accurate, with a geomean overhead under 10% and a byte accuracy of 93%. We evaluate ZRay on x86-64 and demonstrate functionality on AArch64, RISC-V and POWER8, showing that compiler-assisted instrumentation can provide portable, low-overhead memory characterization.