When Cache Reads Cost More Than Computation: The Underestimated Price of Cache Hits

    This article examines a case where a shared attention cache in a long-context Mixture-of-Experts deployment left median latency unchanged but raised P99 latency from 3.96 seconds to 17.3 seconds. It explains why reading a cached result can cost more than recomputing it, how to model the break-even point, and how to redesign caching with cost checks, chunking, overlapped prefetching, traffic isolation, and better metrics.

    One Optimization Amplified Tail Latency by 4x

    A super-large Mixture-of-Experts (MoE) model was deployed on an 8-GPU node for long-context inference. To return similar requests faster, the team added a shared cache that stored previously computed attention intermediate results. The goal was for later requests to reuse these results and skip repeated computation.

    The outcome did not match expectations. After the cache was enabled, median latency barely changed, but P99 latency for the slowest 1% of requests rose from 3.96 seconds to 17.3 seconds. Engineers eventually rolled back the entire caching feature to restore stability.

    This was not a simple case of a low cache hit rate. The real problem was that reading from the cache has a cost, and that cost was seriously underestimated during system design.

    First, Why the Model Needs a Cache

    The model uses a Mixture-of-Experts architecture. Its total parameter count is very large, but each inference step activates only a subset of experts. This lets the model scale up without a proportional increase in compute.

    Its attention layers use a compressed design called Multi-head Latent Attention (MLA). In simple terms, the key-value information for each token is compressed into a shared low-rank vector. No matter how many attention heads the model has, the intermediate data stored per token has a fixed size, and that size is relatively small.

    In this case, at FP8 precision, every 256 tokens are packed into one block. Each block is about 12.4 MB, or about 48.4 KB per token on average. This already looks well compressed. However, with long contexts, the cumulative read volume is still large. For example, at a 128K context, the theoretical size of the cache blocks alone reaches about 6.2 GB.

    So the question becomes: when the cached result is large, reading it is not necessarily cheaper than recomputing it.

    Why a Cache Hit Can Still Be Slow

    A cache hit means the system does not need to compute the result again. It retrieves the previous result and reuses it.

    On real hardware, however, retrieval is not free. It includes at least:

    • Looking up the cache index;
    • Locating the corresponding cache block;
    • Moving data from the storage medium to the compute unit;
    • Handling contention and queuing under concurrent access;
    • Adding overhead for deserialization, decompression, or format conversion after a hit.

    In long-context inference, attention is typically memory-bound. For each new token, the model must read the key-value states of all previous tokens. A shared cache avoids repeated computation, but it does not avoid repeated reads. If cache blocks are not located close to the compute units, the read overhead gets amplified.

    A simplified return model illustrates this:

    • C: time required to complete the computation without reading from the cache;
    • R: time required to read from the cache on a hit;
    • M: extra overhead on a cache miss;
    • h: cache hit rate.

    The expected latency with caching is approximately:

    [
    T = h \times R + (1-h) \times (C+M)
    ]

    Caching yields a positive return only when:

    [
    R + \frac{(1-h)}{h} M < C
    ]

    This inequality makes two points. First, the read cost R on a hit must be significantly smaller than the recomputation cost C. Second, the extra overhead M on a miss must also be controllable. If R approaches or exceeds C, a high hit rate can still mean the system is trading computation for a slower path.

    Why the Median Stayed Flat While the Tail Exploded

    A stable median shows that most requests were not significantly affected. These requests likely had shorter contexts and smaller cache blocks, so the difference between reading from the cache and computing directly was too small to show up in their latency.

    The spike at P99 shows that the impact fell on a small set of heavy requests. These requests usually have long contexts, need to read many cache blocks, or compete with other requests for the shared cache. Higher concurrency makes queuing on the cache read path more pronounced. A hit may sound fast, but for the 99th-percentile requests, all cache reads compete for the same bandwidth and lock path, so tail latency degrades quickly.

    This reveals a common misconception: judging cache benefit by average latency hides the high cost on the tail path.

    Turning the Cache into a Real Accelerator

    Solving “the cache is slower than computing” does not simply mean turning the cache off. The cache needs a budget, boundaries, and a way to be bypassed.

    1. Calculate the Cost Before Using the Cache

    Before deciding whether to use the cache, estimate the read cost and the recomputation cost for the current request:

    • Read cost ≈ context length × cache bytes per token ÷ effective memory bandwidth;
    • Recomputation cost ≈ context length × FLOPs per token ÷ effective compute throughput;
    • If the read cost is higher than the recomputation cost, bypass the cache and recompute directly.

    A simple illustrative implementation:

    1. def should_use_cache(context_len, bytes_per_token, flops_per_token,
    2. memory_bandwidth, compute_throughput):
    3. # Estimated time to read the cached data for this request
    4. read_cost = context_len * bytes_per_token / memory_bandwidth
    5. # Estimated time to recompute the same data
    6. compute_cost = context_len * flops_per_token / compute_throughput
    7. return read_cost < compute_cost

    This approach does not assume that caching is always beneficial. It chooses the faster path for each request.

    2. Chunk the Cache Instead of Caching Entire Sequences

    Reuse in long contexts often concentrates on a particular prefix or range. Rather than caching an entire long context as one unit, split it into smaller blocks and decide for each block whether it is worth reusing.

    Keep frequently reused blocks in a fast cache. Skip caching for rarely reused blocks, or move them to a slower tier. Evict blocks that have expired or are no longer referenced as soon as possible. This reduces read amplification, which occurs when a large block is read but only a small part of it is used.

    3. Overlap Cache Reads with Computation

    Cache reads should not block the current computation. A better design runs cache reads and compute in separate pipeline stages, so the computation for the current step overlaps with prefetching for the next step. When the data arrives, it feeds directly into the next round.

    If cache reads and computation run serially, every hit follows this sequence:

    wait for read → start computation

    With overlap, the sequence becomes:

    compute the current step while reading the data needed for the next step in the background

    This matters most in high-concurrency, long-context scenarios.

    4. Apply Traffic Control and Isolation to the Shared Cache

    The shared cache serves all requests. If one large request reads many cache blocks at once, it can take bandwidth from other requests. A more reasonable approach sets a read quota for each request, rate-limits global cache bandwidth, and prevents one request class from starving the others.

    Also isolate the hit path from the miss path. If the hit path becomes slow, it should not degrade tail latency for requests that miss.

    5. Redefine the Monitoring Metrics

    Cache hit rate alone is not enough. More useful metrics include:

    • Cache read latency;
    • Average bytes read from the cache per token;
    • Whether each hit yields a positive return;
    • P95 and P99 latency changes before and after enabling the cache;
    • Whether cache reads have become a critical-path bottleneck.

    Hit rate is an efficiency metric, while latency is an outcome metric. A system can have a high hit rate in which every hit is slow, and still slow down the overall service.

    Conclusion

    A cache is not a natural accelerator. It trades storage cost for compute cost. When computation is already fast and memory access is the bottleneck, reading from the cache can be slower than computing directly.

    The most valuable takeaway from this case is that before optimizing with any cache, you should ask what the cache actually saves, what reading it costs, and whether that accounting still holds for long contexts, high concurrency, and shared workloads.

    If you can answer these questions well, the cache can move from a drag on the system to a reliable accelerator. If you cannot, adding a cache may be the source of the next tail-latency incident.