Inference Server Cache Performance Testing Suite

July 12, 2026 · View on GitHub

A toolkit for testing and benchmarking LLM inference servers and their KV Cache offload performance.

Quick Start

# Install dependencies (using uv - recommended)
uv pip install -r requirements.txt

# Or with pip
pip install -r requirements.txt

# Run a simple single-prompt test
uv run python single_prompt_tester.py \
    --api-endpoint http://localhost:8000 \
    --min-tokens 1000 \
    --max-tokens 128000 \
    --output-dir results

# Test various cache hit rates (sustained mode - default)
uv run python cache_rate_tester.py \
    --api-endpoint http://localhost:8000 \
    --context-sizes 8000 32000 64000 \
    --working-set-size 2000000 \
    --max-ttft 2.0 \
    --output-dir output

# Test performance across different memory tiers
uv run python working_set_tester.py \
    --api-endpoint http://localhost:8000 \
    --context-sizes 30000 \
    --min-working-set-size 100000 \
    --max-working-set-size 5000000 \
    --working-set-increments 10

# Replay real agentic coding traces
uv run python trace_replay_tester.py \
    --api-endpoint http://localhost:8000 \
    --trace-directory traces \
    --output-dir output \
    --start-users 5 \
    --max-users 50 \
    --max-ttft 2.0 \
    --test-duration 300

Core Testing Tools

ToolPurposeDocumentation
single_prompt_tester.pyBaseline cache performance with cold start vs cached comparisonsDocs
cache_rate_tester.pyPerformance at various cache hit rates (0-100%) with fixed working setDocs
working_set_tester.pyPerformance across varying working set sizes for memory tier analysisDocs
trace_replay_tester.pyReplay real agentic coding traces with realistic cache patterns and timing (beta)Docs

Included Traces

The traces/ directory contains 739 traces with 59,204 requests, including 19 traces with nested sub-agent conversations (70 sub-agents total). Generated from real Claude Code sessions captured via claude-code-proxy as part of research at WEKA on the Augmented Memory Grid product. See agentic-coding-analysis for the trace generation tools.

Traces include:

  • Local hash_ids (hash_id_scope: "local") — hash IDs are scoped per conversation, with sub-agents sharing the parent's namespace
  • Timing breakdownapi_time (server processing) and think_time (client delay) per request, enabling flexible replay timing strategies
  • Sub-agent nesting — sub-agents embedded in parent traces with their own tool/system tokens and request arrays
  • One request per turn — no streaming/non-streaming pairing (proxy bug fixed upstream)

All traces are fully anonymized — no conversation IDs, timestamps, or real agent IDs.

MetricMinP25MedianP75MaxMean
Requests per trace319481011,17880
Starting input tokens6,34318,72624,775105,061851,85892,473
Ending input tokens11,05394,686137,529208,960894,371181,659
Input tokens per request (P10/P50/P90)43,475109,903300,118139,924
Output tokens per request (P10/P50/P90)103218937446
Conversation duration (min)0.123621414,952240
Think time per request (s)06103078,638199
API time per request (s)1.24.46.511.0300.010.2

Cache hit rates

Cache rates are computed from hash_id overlap between consecutive requests within each conversation.

ScenarioMinP25MedianP75MaxMean
Conversation-only (no warm prefix)61%92%96%97%100%93%
With 75% warm prefix67%93%96%97%100%94%

System and tools prefix impact: Each trace includes tool_tokens (median ~10,500) and system_tokens (median ~2,600) — a combined prefix of ~15,000 tokens (median), representing ~60% of the median first-request input. In a production deployment, this prefix is shared across all conversations and stays warm in the KV cache, so the first request of any conversation gets a significant cache hit that isn't captured by the conversation-only rate above. The "75% warm prefix" row models 75% of the tools+system prefix being cached on the first request — this primarily benefits short conversations where the first-request miss dominates. For longer conversations, the prefix is a small fraction of total tokens and the impact is minimal (~1pp).

Utility Scripts

ToolPurpose
generate_index.pyGenerate HTML dashboard from test results
regenerate_graphs.pyRegenerate graphs from existing CSV data
combine_graphs.pyCombine results from multiple runs for comparison
kv_cache_size.pyCalculate KV cache memory requirements

See Utilities Documentation for details.

Installation

We recommend using uv for fast, reliable Python package management.

# Clone the repository
git clone https://github.com/callanjfox/kv-cache-tester.git
cd kv-cache-tester

# Install dependencies with uv (recommended)
uv pip install -r requirements.txt

# Or with pip
pip install -r requirements.txt

# Verify installation
uv run python single_prompt_tester.py --help

Understanding the Metrics

  • TTFT (Time To First Token): Latency before first token generation - primary metric for cache effectiveness
  • TTLT (Time To Last Token): Total request completion time
  • ITL (Inter-Token Latency): Time between generated tokens
  • Input/Output Throughput: Tokens processed/generated per second

Testing Methodology

For a detailed guide on testing methodology and how to use these tools effectively, see: Evaluating Management of KV Cache within an Inference System

Note: This guide will be updated soon with the latest methodology covering trace replay testing and multi-endpoint support.

Real-World Trace Replay

Beta: trace_replay_tester.py is currently in beta with active development underway. Updates to come.

The trace_replay_tester.py tool replays real agentic coding traces to benchmark inference performance with realistic cache hit patterns, timing, and message structures. See the Trace Replay Documentation for full details.