# How Much Token Reduction Does CRG Achieve Compared to Whole-Corpus Approaches?

> Discover how much token reduction CRG achieves versus whole-corpus methods. CRG offers a median 65x reduction, with improvements up to 376x in real-world code.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: performance
- Published: 2026-08-08

---

**Code Review Graph (CRG) typically achieves a median token reduction of 65× compared to whole-corpus approaches, with observed improvements ranging from 65× to 376× across real-world repositories.**

The `tirth8205/code-review-graph` repository implements a graph-based retrieval system that fundamentally changes how LLMs consume codebases during review tasks. Unlike naive approaches that ingest entire repositories, CRG traverses structured code relationships to deliver precise context. This architectural difference produces dramatic token efficiency gains that directly impact API costs and latency.

## Understanding CRG Token Reduction Metrics

The project's benchmark suite, implemented in [`eval/benchmarks/token_efficiency.py`](https://github.com/tirth8205/code-review-graph/blob/main/eval/benchmarks/token_efficiency.py), quantifies the delta between whole-corpus ingestion and graph-based retrieval across six production repositories.

### Median 65× Reduction Across Benchmarks

According to the benchmark data in [`README.md`](https://github.com/tirth8205/code-review-graph/blob/main/README.md), the **median per-question token reduction is approximately 65×** when comparing CRG to whole-corpus baselines. This means a typical query that would consume 200,000+ tokens using naive retrieval requires only around 3,000 tokens via the graph approach.

### Extreme Cases: Up to 376× on Large Monorepos

The largest observed improvement reaches **376× on the FastAPI monorepo**, the biggest repository in the test suite. This super-linear scaling demonstrates that CRG's efficiency gains compound as codebase size increases, whereas whole-corpus approaches suffer linear token growth.

## Real-World Token Savings in Production Codebases

Concrete measurements from the [`code_review_graph/token_benchmark.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/token_benchmark.py) definitions reveal the practical impact across different repository sizes.

For the **Flask repository**, a whole-corpus query consumes **143,594 tokens**, while the identical question answered via CRG uses only **2,196 tokens**—a **71× reduction**.

Typical architectural queries show similar patterns. When asking "how does authentication work?", the full source token count of approximately **208,821 tokens** collapses to roughly **3,190 tokens** per question, reflecting a **~66× reduction** according to the benchmark tables in [`README.md`](https://github.com/tirth8205/code-review-graph/blob/main/README.md).

## How CRG Achieves Two Orders of Magnitude Efficiency

The token savings stem from CRG's selective graph traversal rather than wholesale ingestion. While [`eval/benchmarks/token_efficiency.py`](https://github.com/tirth8205/code-review-graph/blob/main/eval/benchmarks/token_efficiency.py) measures the raw token counts, the underlying architecture avoids loading files irrelevant to the specific review question.

Whole-corpus approaches inevitably import dead code, comments, and unrelated modules. CRG's graph structure—defined in the core traversal logic—follows call graphs, import chains, and semantic relationships to retrieve only the minimal necessary context.

## Implementing Token-Budgeted Queries

You can observe these savings directly using the CLI implemented in the repository. The `--budget` parameter enforces token constraints that mirror the benchmark conditions:

```bash

# Baseline: whole-corpus query (high token count)

code-review-graph query --repo myrepo --question "Explain authentication flow"

# CRG-optimized query (token-budgeted graph traversal)

code-review-graph query --repo myrepo --question "Explain authentication flow" --budget 5000

```

The first command may ingest over 100,000 tokens; the second stays under a few thousand, reflecting the typical 65–70× token savings demonstrated in the benchmark suite.

## Summary

- **CRG achieves a median 65× token reduction** compared to whole-corpus approaches across six benchmark repositories.
- **Extreme cases reach 376× reduction** on large monorepos like FastAPI, showing super-linear scaling benefits.
- **Practical queries** such as authentication flow analysis demonstrate **66–71× reductions**, collapsing 200,000+ token contexts to under 3,500 tokens.
- The **[`eval/benchmarks/token_efficiency.py`](https://github.com/tirth8205/code-review-graph/blob/main/eval/benchmarks/token_efficiency.py)** module provides reproducible measurements of these savings.
- **Token-budgeted CLI flags** (`--budget`) allow developers to enforce the same efficiency constraints in production workflows.

## Frequently Asked Questions

### What is the typical token reduction ratio when using Code Review Graph?

The typical token reduction achieved by CRG compared to whole-corpus approaches is approximately **65×** (65 times fewer tokens), based on median measurements across six real-world repositories in the benchmark suite.

### How does repository size affect CRG's token efficiency?

Larger repositories see greater absolute savings. While the median reduction is 65×, the FastAPI monorepo achieved a **376× reduction**—the largest observed improvement—indicating that CRG's graph-based retrieval provides disproportionate benefits as codebase scale increases.

### Which files contain the token reduction benchmarks in the CRG repository?

The primary benchmark data resides in **[`README.md`](https://github.com/tirth8205/code-review-graph/blob/main/README.md)** (lines 52-216), with the measurement logic implemented in **[`eval/benchmarks/token_efficiency.py`](https://github.com/tirth8205/code-review-graph/blob/main/eval/benchmarks/token_efficiency.py)** and sample question definitions in **[`code_review_graph/token_benchmark.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/token_benchmark.py)**.

### Can I enforce token budgets when running CRG queries?

Yes. The CLI supports the **`--budget`** flag (e.g., `--budget 5000`) to limit token consumption during graph traversal, allowing you to replicate the 65× token savings observed in the benchmarks during production use.