Headroom

Benchmarks

Compression performance, accuracy preservation, and latency overhead, measured on reproducible local benchmarks.

Headroom's core promise: compress context without losing accuracy. This page covers compression benchmarks, accuracy evaluations, and latency overhead. Every number below is measured locally and reproducible (see Reproducing Results).

For local inference, the main benefit is often faster prompt processing rather than lower API spend. See Local LLM prefill benchmarking for a reproducible passthrough-vs-optimized proxy workflow.

Compression Performance

Measured on Apple M-series (CPU), Headroom 0.37.0, via python benchmarks/bench_latency.py (10 warm iterations per scenario; latency is p50 compression overhead, not an LLM call).

Content TypeOriginalCompressedSavedRatioLatency (p50)
JSON array — search results (100 items)10,2005,3004,90048%0.20ms
JSON array — search results (500 items)50,20025,80024,40049%0.77ms
Structured logs (100 entries)7,6003,6004,00053%0.17ms
Structured logs (500 entries)35,70016,20019,40054%0.51ms
Documentation text (20K tokens)20,1001,60018,40092%1.4ms
Python source (~200 lines)2,6002,60000.0%1.3ms
Total126,40055,10071,30056%4.4ms

Zero compression is intentional

Python source shows 0% compression: SmartCrusher only compresses JSON arrays, and code passes through to preserve correctness (verified: headroom/transforms/smart_crusher.py:242).

Accuracy Benchmarks

HTML Extraction

Dataset: Scrapinghub Article Extraction Benchmark (181 HTML pages with ground truth), via allenai/scrapinghub-article-extraction-benchmark on Hugging Face.

MetricValue
F1 Score0.919
Precision0.875
Recall0.985
Compression94.8%

For LLM applications, recall is critical -- 98.5% means nearly all article content is preserved. The slight precision drop (some extra content) does not hurt LLM accuracy.

JSON Compression (SmartCrusher)

Test: 100-entry JSON log array with one anomalous error entry (error code, resolution, and affected count) injected at position 67, compressed via the public compress() API with an OpenAI-format tool-result message.

MetricValue
Input tokens (before)4,937
Input tokens (after)3,053
Compression38.2%
Error entry preserved in outputYes (verified by substring check)

SmartCrusher preserves first N items (schema), last N items (recency), all anomalies (errors, warnings), and statistical distribution. This test confirms the anomalous entry survives compression; it does not include an LLM-graded "correct answers" comparison, which would require a paid API call to reproduce.

QA Accuracy Preservation

Requires a paid LLM call to reproduce

This comparison (tests/test_evals/test_html_oss_benchmarks.py::TestQAAccuracyPreservation) runs SQuAD questions against both the original HTML and the extracted text using an LLM judge, and only executes when OPENAI_API_KEY is set. No committed result artifact for it exists in this repo, so no number is published here. Set OPENAI_API_KEY and run pytest tests/test_evals/test_html_oss_benchmarks.py -k qa_accuracy -v -s to reproduce it yourself.

Latency Overhead

SDK Compression Latency

Measured per-scenario on Apple M-series (CPU) via python benchmarks/bench_latency.py --scenario json --iterations 10. This is the local compression pipeline's own overhead — no LLM call is involved.

ScenarioTokens InTokens OutSavedp50 (ms)p95 (ms)
JSON: Search Results (100 items)10.2K5.3K4.9K0.200.21
JSON: Search Results (500 items)50.2K25.8K24.4K0.771.1
JSON: Search Results (1K items)100.5K51.7K48.8K1.41.6
JSON: API Responses (500 items)38.9K21.8K17.0K0.770.80
JSON: Database Rows (1K rows)43.7K16.2K27.5K0.780.81
JSON: String Array (100 strings)1.1K2268250.150.16
JSON: String Array (500 strings)4.9K2284.6K0.110.12
JSON: Number Array (200 numbers)1.2K1461.1K0.170.18
JSON: Mixed Array (250 items)2.3K1.1K1.2K0.240.25

Cost-Benefit Analysis

Net latency benefit = LLM time saved from fewer tokens minus compression overhead (at Claude Sonnet 4.5's 0.03ms/token prefill rate, $3.0/MTok input pricing):

ScenarioCompress (ms)LLM Saved (ms)Net BenefitSavings per 1K Requests
JSON: Search Results (100 items)0.20146+145.8ms$14.60
JSON: Search Results (500 items)0.77731+730.2ms$73.09
JSON: Search Results (1K items)1.41,464+1,462.6ms$146.40
JSON: API Responses (500 items)0.77511+510.2ms$51.10
JSON: Database Rows (1K rows)0.78824+822.9ms$82.36

Compression paid for itself in latency for all 25 compressing scenarios measured (JSON, structured logs, agentic multi-turn, and long-document text) against Claude Sonnet 4.5. Slower and more expensive models (Opus) benefit even more, since the same compression overhead offsets a larger per-token prefill cost.

Pipeline Step Timing

Measured via the same bench_latency.py run's per-transform breakdown (content detection + routing is the dominant step in every JSON scenario):

Scenariocontent_router p50% of total pipeline time
JSON: String Array (500 strings)0.08ms68%
JSON: Search Results (100 items)0.16ms82%
JSON: Mixed Array (250 items)0.21ms85%
JSON: Database Rows (1K rows)0.72ms95%
JSON: Search Results (5K items)6.6ms99%

ContentRouter accounted for 68--99% of pipeline cost across the 14 JSON scenarios measured (mean ~87%), the rest going to tokenization and the compression transform itself.

Reproducing Results

git clone https://github.com/headroomlabs-ai/headroom.git
cd headroom
pip install -e ".[evals,html]"
pytest tests/test_evals/ -v -s

# Latency and compression-ratio tables above
python benchmarks/bench_latency.py

On this page