The Hidden Cost of Cache Reads: A Technical Postmortem of a High-Latency Incident and Our Remediation Strategy
This article examines a real-world performance incident in an inference service cluster, where enabling a shared cache for attention intermediates unexpectedly caused p99 latency to spike from 3.96 seconds to 17.3 seconds. It traces the root cause to underestimated I/O costs in cache read paths—bandwidth contention, random access patterns, and lock contention—and details the three-layer redesign that restored stable tail latency. The article concludes with practical guidelines for evaluating cache value in end-to-end latency terms rather than hit rate alone.
A Baffling Performance Regression
Engineers at a major cloud provider were operating an online inference service for a large-scale Mixture-of-Experts (MoE) model deployed on a single node with 8 high-performance GPUs. The model used a leading-edge sparse activation architecture, and the team had introduced a shared cache layer to store intermediate attention results from previous computations. The intent was straightforward: reuse those cached results on subsequent requests and reduce redundant computation, thereby improving time-to-first-token in long-context scenarios.
The performance test results, however, were confounding. With caching enabled, the median latency barely moved, but the slowest 1% of requests—the p99 latency—deteriorated dramatically from 3.96 seconds to 17.3 seconds, a more than fourfold increase. The engineers eventually rolled back the feature completely to restore the original service quality.
This was not a logical flaw in the cache design itself. It was a deeper issue: reading from cache has a non-negligible cost, and that cost was severely underestimated at the design stage.
Understanding the True Cost of Cache Through the Model Architecture
To analyze why caching backfired, we need to examine both the model’s computational characteristics and the GPU’s hardware data path.
The model used Multi-head Latent Attention (MLA). This technique compresses key-value information for each token into a shared low-rank vector, significantly reducing the amount of intermediate data that needs to be stored. Theoretically, this provided an excellent foundation for caching—each token required only a few tens of kilobytes of intermediate storage, far less than the hundreds of kilobytes or even megabytes typical of traditional attention mechanisms.
In this specific deployment, the model ran at FP8 precision. Every 256 tokens were packed into one cache block, occupying approximately 12.4 MB of storage. From a pure capacity standpoint, the design was nearly perfect: a single GPU node carried hundreds of gigabytes of high-bandwidth memory (HBM), and the cache footprint was minimal.
But the problem was never about capacity. It was about the data path.
The Hidden Cost of Reading Cache: Bandwidth Contention and Path Latency
The cache mechanism in attention computation is, in essence, the inverse of the classic “trade compute for bandwidth” equation—it attempts to substitute stored results for recomputation. However, in GPU hardware architecture, reading from HBM and executing tensor computations traverse entirely different physical paths. As cache hit rates rise, the GPU must frequently fetch cache blocks from HBM rather than relying on registers or on-chip cache. Every cache read consumes HBM bandwidth.
The crux is this: GPU memory bandwidth is not only the supply channel for compute units; it is also the bottleneck for multi-GPU communication. In production, the 8 GPUs are interconnected via a high-speed fabric that simultaneously carries tensor transfers from model parallelism and data movement from cache reads. When a large number of concurrent requests trigger cache reads, memory bandwidth saturates rapidly, and the latency of all memory operations—including model weight loading and activation value reads/writes—increases across the board.
What’s even more insidious is that the cache read path is not a lock-free fast lane. The shared cache is managed by a global index table, and concurrent requests across multiple GPUs must query and update this index. At low load, this bookkeeping is imperceptible. But as request concurrency spikes, index lock contention becomes severe, and wait times grow exponentially.
The observed phenomenon—p99 latency soaring while the median barely changed—exactly exposes this dynamic: while the majority of requests experience little contention, a minority get trapped in extraordinarily long queues due to bandwidth competition and lock waiting. The cache did not eliminate computational cost; it merely converted it into another form of waiting cost.
A Key System-Level Insight: Weight Reads and Cache Reads Are Not the Same
Further analysis surfaced a critical finding: when the GPU executes matrix multiplication, the reading of weight parameters is a highly predictable, streaming access pattern. It can leverage prefetching and pipelining to hide latency. Cache reads, by contrast, depend on the input content of each request—they are random access patterns. Random access cannot benefit from prefetch optimization; every hit requires traversing the full memory latency path.
When the cache size exceeds the GPU’s L2 cache capacity, these random reads inevitably spill into HBM. While HBM latency is far lower than main memory, it remains an order of magnitude higher than on-chip cache. In a dense stream of inference requests, this latency is repeatedly amplified. The “compute time” saved by each cache hit may look impressive in isolation, but the “access wait time” introduced after the hit nearly cancels out the gain.
A decisive test confirmed this diagnosis: with caching fully disabled, p99 latency immediately returned to ~3.9 seconds. With caching enabled but cache reads restricted to a single GPU, latency improved only marginally and remained unsatisfactory. This proved the issue was not data correctness in the cache, but that the cache path’s data throughput could not keep pace with the compute units’ consumption rate.
Redesigning the Cache: From Best-Effort Reads to Aware Scheduling
Once the root cause was clear, the team rebuilt the cache system. The core principle shifted from chasing hit rates to treating cache reads as full I/O operations, guided by a three-layer optimization strategy.
Layer 1: Topology-Aware Cache Routing. The cache index now incorporates GPU topology-aware scheduling. Each GPU prioritizes reading cache blocks from its local HBM. If the required data is not local, it can be fetched from a neighboring GPU via the high-speed interconnect—but only when current bandwidth utilization is low. If the interconnect link is congested, the system discards the cache hit and recalculates on the fly.
Layer 2: Hierarchical Cache Storage. The original single-tier global cache pool was split into two levels. The first tier resides in the GPU’s L2 cache, holding only a small set of extremely hot blocks. The second tier remains in HBM as backing storage. A cache block is promoted to the L2 tier as its access frequency rises, and evicted back to HBM as popularity fades. This way, frequently hit requests use the fastest path, while cold data does not occupy scarce on-chip cache.
Layer 3: Dynamic Bypass Policy. The system continuously monitors GPU compute utilization and memory bandwidth utilization. When bandwidth utilization exceeds a threshold, cache read priority is automatically lowered, and some requests are routed directly to the compute path. Conversely, when compute units are idle and bandwidth is plentiful, the cache path is preferred. This transforms the cache from a fixed mechanism into an adaptive policy.
These three layers are not isolated designs. They converge on a single principle: the value of a cache must be evaluated from end-to-end latency, not measured by hit rate alone. A cache with a 90% hit rate but extremely high per-hit latency may perform far worse than one with a 60% hit rate but very low hit latency.
Lessons and Methodology: How to Properly Evaluate Cache Benefits
This incident holds a deeper lesson: it challenges the naive assumption that “caching inherently improves performance.” In high-throughput, low-latency system design, evaluating whether a cache scheme is worth deploying requires answering at least three questions.
First, what is the relative cost of a cache read? What is the true ratio between the time to compute an intermediate result and the time to read it from storage and transfer it to the compute unit? Many designers compare only “compute latency” and “cache access latency,” missing the added queuing delay, lock contention, and bandwidth competition that cache access can introduce.
Second, does the cache negatively affect tail latency? Average latency and p99 latency reflect two different dimensions of system performance. If cache-induced extra waiting concentrates on a small minority of requests, the cache design has problems—regardless of how benign the average looks. Capacity planning must use p99 or even p999 latency as the threshold, not the mean.
Third, are cache benefits stable and predictable? If the workload distribution fluctuates sharply, hit-rate volatility can translate into higher latency variance. For workloads like online inference that demand strict stability, a cache system with high variance can be more dangerous than no cache at all.
From “Cache Is Useless” to “Cache Is Usable”: A Corrected View
In traditional system design, caching is viewed as an almost free acceleration technique—the more cache, the better, as long as capacity allows. Modern GPU computing systems shatter that assumption. Compute speed has grown far faster than memory and network bandwidth, making “data movement” an increasingly dominant share of the total request lifecycle.
The value of this case study goes beyond fixing a specific problem. It provides a methodological evaluation path: any system optimization must be examined within the full end-to-end request chain, not measured in isolation. What matters is not how many times the cache hits, but how much perceptible waiting time each hit saves for the user request.
In the end, the team redeployed the redesigned cache system. P99 latency settled at approximately 4.1 seconds—still slightly higher than the pure-compute baseline of 3.96 seconds—but the overall outcome was positive. The cache freed up significant compute resources during idle periods, and classification accuracy in long-context scenarios improved notably, because shared caching effectively enabled cross-request knowledge reuse.
This practice reminds us that in the world of performance optimization, no technique can be applied without scrutiny. Caching, prefetching, and parallelization—these classic techniques—all require re-examination of their hidden costs under new hardware architectures. The reliable approach is to validate every assumption with data and measure every optimization by end-to-end latency metrics. This is not just a lesson for cache design; it is a general methodology for performance engineering in any large-scale system.
