arXiv:2610.26849cs.DBOct 2026

Manuscript Offprint

arXiv:2610.26849

SARP: An On-SSD Index for KVCache with Fast Prefix Matching and Recovery

Jun Kong, Qi Lin, Zhichao Cao

Abstract

Distributed LLM serving systems rely on a global index to locate reusable key-value cache (KVCache) blocks through prefix matching. If the index is lost after a crash or restart, affected requests cannot locate existing KVCache and recompute it on GPUs. Systems therefore persist the index to restore access to KVCache after a failure. Existing persistent indexes face a tension between prefix-matching performance and recovery time. A snapshot-backed in-memory index supports fast prefix matching, but rebuilding the full index from a snapshot lengthens recovery time. An on-SSD index avoids this rebuild, but adds storage accesses to prefix matching.

Our core insight is that extending a matched prefix over the next short span typically requires distinguishing among only a few candidate token sequences. This suggests that sparse in-memory routing state may suffice to distinguish them. Prefix matching also accesses block metadata in sequence order, allowing metadata for consecutive blocks to be retrieved together. Based on these observations, we present SARP (Sparse Adaptive Routing and Packing), an on-SSD KVCache index for fast recovery and prefix matching. SARP groups consecutive block IDs and metadata into segments to amortize storage accesses across multiple blocks. A compact in-memory routing directory identifies candidate segments using entries at selected block positions. SARP limits segment retrievals and uses compact filters to prioritize candidates with longer potential matches. After retrieval, SARP compares each segment's block IDs with the query's block IDs and reuses only the KVCache blocks covered by the verified prefix. After a restart, SARP restores the sparse routing directory from a snapshot. Across four multi-turn chat and agentic workloads, SARP recovers 8.0×8.0\times to 77.5×77.5\times faster than the in-memory index baselines and delivers 1.15×1.15\times to 66.6×66.6\times the request throughput of the on-SSD index baselines, while reusing only 0.0030% to 0.029% fewer tokens than exact prefix matching.

1 Introduction

During large language model (LLM) inference, two requests under the same model and configuration that share a token-level prefix produce the same key and value tensors for that prefix. Serving systems therefore retain these tensors in fixed-length KVCache blocks, so later requests with the same prefix can reuse the corresponding KVCache blocks instead of recomputing them on GPUs [15, 42]. This KVCache reuse is common within a chat session because each turn extends the preceding history [12], and across sessions when requests share system prompts and documents [17]. Claude Code and Codex traces show that 95.7% of input tokens hit the prefix cache [45]. Because a GPU node's memory cannot hold all reusable KVCache blocks, serving systems offload them to CPU memory, local SSDs, and distributed storage systems [1, 19, 28, 32]. A reusable KVCache block can therefore reside on a different node or storage tier from the GPU that needs it.

To locate these blocks across GPU nodes and storage tiers, distributed LLM serving systems maintain a global KVCache index [1, 20, 26]. The index organizes block metadata by token sequence and records where each cached block is available, such as its GPU node and storage tier. It supports two operations. Prefix matching compares a request's token sequence with indexed sequences, finds the longest matching prefix whose KVCache blocks are available, and returns that prefix's block metadata in token order. Prefix insertion registers a processed sequence with the block metadata of its cached KVCache blocks so later requests can find and reuse them. Existing systems implement these operations with radix-tree or block-hash indexes. SGLang and NVIDIA Dynamo use radix-tree-based indexes, whereas Tair KVCache, Mooncake, vLLM, and llm-d use block-hash indexes [1, 20, 29, 32, 37, 42]. A radix-tree index represents shared prefixes as paths in a compressed tree. A block-hash index maps each block's chained block ID, computed from that block and the preceding ID, to its block metadata. The chained ID identifies the prefix that ends at that block.

The in-memory global indexes keep prefix matching fast, but crashes and restarts can make their index state unavailable. When this state is lost, inference requests cannot locate offloaded KV-Cache blocks and have to recompute their reusable prefixes. Systems preserve index availability in two ways. Replication keeps the index available while a surviving replica remains, as in NVIDIA Dynamo [29]. Persistence saves the index state so it can be restored later. Mooncake takes snapshots natively [26, 46], FlexKV uploads its index to Redis [11], and Tair KVCache persists its metadata in an external key-value store [1].

A snapshot-backed in-memory index is durable, but it cannot serve prefix-matching requests immediately after a restart. Its snapshot stores serialized index state, so recovery has to load the entries and rebuild the DRAM index before serving requests. Recovery time therefore grows with the number of block-metadata entries, and requests cannot locate offloaded KVCache blocks during recovery. Table 1 reports this recovery time at one billion block-metadata entries: 621 seconds for Redis, approximately 33 minutes for Mooncake, and approximately 52 minutes for Dynamo 1.3. Requests therefore have to recompute their reusable prefixes throughout this recovery time.

An on-SSD index keeps its index representation in SSD-backed durable storage. Once the storage backend has recovered, it can serve prefix-matching requests without rebuilding a full copy in DRAM. This placement shortens recovery time, but prefix matching now retrieves index records from storage and therefore incurs storage-access cost. A key-value store such as RocksDB provides one example of this placement [23]: a block-hash index stores one key-value record for each block-hash entry, whereas a radix-tree index stores one record for each tree node. A prefix match may retrieve a chain of records along the shared prefix, so one match can require multiple record retrievals.

Figure 1 shows that the evaluated RocksDB-on-NVMe implementations raise mean prefix-match latency by 39×39\times to 402×402\times relative to their DRAM counterparts across the four workloads. A snapshot-backed in-memory index requires rebuilding after a restart, whereas an on-SSD index avoids that rebuild but adds storage-access cost to prefix matching. This tradeoff motivates our research question: how can a persistent KVCache index reduce both the state rebuilt during recovery and the storage accesses needed for prefix matching?

The workloads offer two properties that create opportunities to address these two costs. First, prefix matching follows a query and a cached sequence from their beginnings. Once they agree through a prefix, cached sequences may diverge in different ways. Matching follows the alternative whose tokens agree with the query and accesses block IDs and their corresponding block metadata in sequence order. This sequence order creates an opportunity to retrieve nearby block IDs and metadata together and amortize storage accesses. Second, after a matched prefix reaches the start of a 256-token span, only a few alternatives appear within most spans. This small number of alternatives suggests that less in-memory state may suffice to distinguish them while block IDs and block metadata remain in durable storage. Across the measured spans, counts exceed three in 21.31% of CodeAct, 0.60% of LMCache-Agent, 1.78% of EABF, and 16.85% of UltraChat.

Using these properties together creates three challenges. First, larger retrieval units amortize storage accesses, but a shared prefix can end inside one unit, so matching only complete units can lose reusable blocks. Retaining routing information for every block preserves such partial matches, but enlarges the in-memory state rebuilt after a restart. Second, spans with many alternatives can require several storage retrievals to determine how far the query matches. A retrieval budget bounds prefix-match cost, but it can leave a longer matching alternative unexamined and reduce KV-Cache reuse. Third, removing routing information can merge distinct alternatives and increase retrievals. The index therefore has to improve discrimination where many alternatives occur, choose which alternatives to compare under a retrieval budget, and minimize restored routing state without sacrificing prefix reuse.

SARP addresses these challenges with an on-SSD segment store and a sparse in-memory routing directory that maps selected prefixes to candidate segments. The segment store groups consecutive block IDs and their corresponding block metadata in one segment record, so one segment retrieval can cover several blocks. After each retrieval, SARP compares the block IDs with the query before reusing any KVCache blocks. To improve discrimination where candidate lists are large, adaptive routing-point refinement adds routing points at selected block positions and narrows the candidates available to later matches. Candidate filtering uses compact filters to estimate how far each candidate may match, prioritizes candidates with larger estimates, and caps segment retrievals per query window. To reduce restored state, adaptive routing-point pruning removes routing points when the preceding candidate list already fits within the retrieval budget while retaining the candidates needed for exact verification. After a restart, SARP restores only the routing directory, while the segment records remain durable.

Across four multi-turn chat and agentic workloads, SARP recovers 8.0×8.0\times to 77.5×77.5\times faster than the in-memory index baselines and delivers 1.15×1.15\times to 66.6×66.6\times the request throughput of the on-SSD index baselines, while reusing only 0.0030% to 0.029% fewer tokens than exact prefix matching.

This paper makes three contributions:

  • We characterize the tension between recovery time and prefix-matching performance in persistent KVCache indexes.

  • We show that sequence-ordered block metadata and the few alternatives that follow most matched prefixes in multi-turn chat and agentic workloads create opportunities to amortize storage accesses and reduce in-memory matching state.

  • We present SARP, which combines an on-SSD segment store with sparse in-memory routing, routing-point refinement, candidate filtering, and routing-point pruning to reduce recovery state and storage accesses while preserving block-level prefix matching.

References (20)