When Caching Is Slower Than Computing: The Truth About Inference Tail Latency

    This article explains why adding a cache to large language model inference can make tail latency worse instead of better. Using a real incident on a large-scale MoE model, it breaks down the hidden costs of cache reads—bandwidth contention, address translation, queueing effects, and scheduling pressure—and shows how long-context workloads turn GB-scale data movement into a bottleneck. It then offers three quantitative gates for deciding whether to cache, a design pattern for making the cache a fail-safe side path, and a rollout strategy based on canary testing, A/B comparison, and second-level rollback.

    1. A Counterintuitive Production Incident: Tail Latency Broke First After Enabling Cache

    A team was serving inference for a very large-scale Mixture-of-Experts (MoE) model on a single node equipped with eight high-performance accelerators. To speed up long-text scenarios, they added a “shared cache” in front of the attention layers. The idea was to store previously computed attention intermediate results so that requests with similar prefixes could hit the cache directly and skip redundant computation.

    The post-launch numbers were awkward: median latency barely moved, but the slowest 1% of requests jumped from about 3.96 seconds to 17.3 seconds. The team’s first instinct was a full rollback. The conclusion from the retrospective came down to one sentence: reading from a cache has a cost, and that cost has long been severely underestimated.

    This is not an isolated case. Any system that introduces caching partially converts a “compute-intensive” problem into a “data-movement-intensive” one. When the movement path and the compute path share the same scarce resources—GPU memory bandwidth, host memory bandwidth, PCIe/NVLink links, address translation units—the cache degrades from an accelerator into a source of interference.

    2. Understand the Workload First: How Large Are Attention Intermediate Results?

    To judge whether caching pays off, first calculate the relative cost of “reading one byte” versus “doing one computation.”

    Take a low-rank compressed attention mechanism as an example (often referred to in the industry as an MLA-style approach). It compresses each token’s key-value information into a shared low-rank vector, so that regardless of the number of attention heads, the intermediate data that must be stored per token is fixed and very small. At FP8 precision, 256 tokens are typically packed into one “block,” and one block is about 12.4MB, which works out to roughly 48.4KB per token.

    These numbers lead to two key implications:

    • The per-token cache is small, so caching seems cheap and casual;
    • But long text is a world of multiplication. A 32K context corresponds to about 1.5GB, and a 128K context corresponds to about 6GB. A single hit means moving gigabytes of data out of GPU memory.

    This is where the core inequality appears:

    1. Benefit ≈ attention compute time saved
    2. Cost ≈ cache data movement time + address translation + slowdown imposed on others from contention + scheduling jitter

    The longer the context and the larger the hit granularity, the more easily the cost terms outweigh the benefit term.

    3. Where the Slowness Comes From: Four Overlooked Cost Paths

    3.1 Bandwidth Contention: You Save Compute but Steal Bandwidth

    Compute capability on modern accelerators grows far faster than GPU memory bandwidth. Attention computation is compute-intensive; cache reads are bandwidth-intensive. When the two run concurrently within the same forward pass, they squeeze each other. The visible result: the request that hit the cache does not get faster, while requests that missed actually get slower—because the available bandwidth has been consumed by moving cache data.

    3.2 Address Translation and Page Table Overhead

    Large cache blocks require contiguous or semi-contiguous address space, involving virtual-to-physical address translation, page table walks, and possible TLB misses. The larger and more fragmented the data blocks, the more significant the translation overhead. This cost does not show up in “amount of computation,” yet it is counted directly in wall-clock time.

    3.3 Tail Amplification: Cache Turns Jitter into an Avalanche

    Median latency is determined by typical requests; P99 is determined by the unluckiest requests. Caching introduces new queueing resources and lock contention points. Once a large block transfer is preempted or queued, the waiting time stacks onto the tail. The jump from 3.96 seconds to 17.3 seconds is essentially tail amplification in a queueing-theory sense, not a degradation of average performance.

    3.4 Scheduling and Memory Pressure

    The cache occupies GPU memory; when GPU memory is occupied, KV space shrinks, batch size is forced down, and throughput drops. Cache eviction brings further jitter. If a synchronous path of “write to cache first, then compute” is used, write amplification is串 directly into the critical path.

    4. Deciding Whether to Cache: Three Quantitative Gates

    Do not enable caching on intuition. Use three gates to make a quantitative judgment first.

    Gate 1: Arithmetic Intensity Ratio

    1. If compute time saved < movement time × (1 + contention factor), do not cache

    The contention factor should be calibrated from production measurements; in long-context scenarios it is often significantly greater than 0.

    Gate 2: Hit Granularity

    Caching by “block” is better than caching by “entire prefix.” Smaller blocks waste less bandwidth, but metadata and translation overhead rise, so a balance point must be found (a common approach is to experiment with 128–512 tokens per block).

    Gate 3: Hit Rate Threshold

    Set a minimum hit rate threshold; below it, turn the cache off entirely. As a rule of thumb, if the hit rate is not enough to amortize the fixed overhead, the cache is pure burden.

    5. The Right Way to Rework It: Make the Cache a “Fail-able” Side Path

    The goal of the rework is not to “make the cache faster,” but to make sure that when the cache is slow, it does not affect the main path.

    5.1 Asynchronization + Admission Control

    • Run hit detection and data movement asynchronously; the main path computes first, uses the cache if it arrives, and ignores it if it does not;
    • Add admission control: initiate a read only when the estimated movement time is less than the remaining compute time;
    • Set a concurrency cap to avoid pile-up of movement tasks.

    Illustrative logic:

    1. def maybe_use_cache(block_id, compute_fn):
    2. # Use the cache only when the data can arrive in time
    3. if est_fetch_us(block_id) < remaining_compute_budget_us():
    4. future = async_prefetch(block_id) # async prefetch, non-blocking
    5. result = compute_fn() # main path computes as usual
    6. cached = future.try_get(timeout=0) # use it if ready, drop it if not
    7. if cached is not None:
    8. return merge(result, cached)
    9. return result
    10. return compute_fn() # give up the cache directly

    5.2 Tiered Caching

    • L1 holds a small number of the hottest blocks: small capacity, fast hits;
    • L2 holds warm blocks: larger capacity, higher latency allowed;
    • Cold data is not cached. The goal of tiering is to make the vast majority of hits happen in L1 and avoid large block transfers.

    5.3 Desynchronize the Write Path

    Move cache writes to the background, using double buffering and batched writes to keep write amplification out of the critical path; the eviction policy should prioritize evicting blocks that are “large but not hot.”

    5.4 Observability Must Come First

    Without measurement there is no optimization. At minimum, collect:

    • Hit rate, and hit latency broken down by block size distribution;
    • Movement bandwidth usage and queueing duration;
    • P50/P95/P99 percentile latency curves comparing cache on versus off;
    • Joint changes in GPU memory usage and batch size.

    6. Rollout Strategy: Canary, A/B Comparison, Second-Level Rollback

    • Feature flag: the cache must be a side-path capability that can be toggled dynamically;
    • A/B experiment: compare P99 under the same traffic, not just the average;
    • Per-scenario enablement: off for short contexts, on for long contexts when the gate conditions are met;
    • Second-level rollback: any tail degradation triggers immediate degradation, with no manual approval chain.

    7. Conclusion

    “Caching is always faster than computing” is a piece of common sense that has been overturned. In inference scenarios with very large-scale MoE and low-rank compressed attention, the benefit of caching is the compute saved, while the cost is the sum of bandwidth, address translation, queueing, and scheduling jitter. The correct engineering answer is not to make the cache more aggressive, but to make it a fail-able, measurable, degradable side path: compute first and fetch later, use block granularity, hit in tiers, write asynchronously. With these four points in place, the cache turns back from a “feature that drags things down” into a true accelerator. If needed, teams can build the comparison experiments and canary system described above on top of a container platform, logging service, and monitoring and alerting, quantifying the benefit and cost of every optimization down to percentile latency.