> For the complete documentation index, see [llms.txt](https://seekspeed.gitbook.io/seekspeed-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://seekspeed.gitbook.io/seekspeed-docs/spec-lab/bottlenecks.md).

# Bottleneck Analysis

The Spec Lab's marquee panel. After a run completes, four scored cards summarise *where* speculative decoding is losing performance against its theoretical ceiling, plus a breakeven curve showing the acceptance rate at which the speedup crosses 1×.

## The four cards

### 1. Draft overhead

```
ceiling   = 1 + k × α
observed  = specTps / baselineTps
overhead  = (ceiling − observed) / ceiling
```

A high overhead score (> 0.4) means the draft model itself is eating most of the gain. Action: try a smaller / more aggressively quantised draft, or lower `num_speculative_tokens`.

### 2. Prefill share

```
prefillShare = ttftMean / totalMean
```

Spec decoding accelerates *decode*, not *prefill*. If prefill is > 60% of total latency, your speedup ceiling is capped at `1 / (1 − prefillShare) × ceiling_decode`. Action: shorten prompts, enable chunked prefill on vLLM.

### 3. Batch pressure

We measure `specTps / baselineTps` at concurrency 1 vs concurrency 4. If the ratio collapses, spec decoding's benefit is being absorbed by batching. Action: keep DSpark on for low-concurrency latency-sensitive routes; turn it off for batch jobs.

### 4. Acceptance rate

The headline. Pulled directly from vLLM's `/metrics`:

```ts
acceptanceRate = vllm:spec_decode_num_accepted_tokens_total
               / vllm:spec_decode_num_draft_tokens_total
```

Color band:

* `α ≥ 0.7` → healthy (most DSpark workloads).
* `0.4 ≤ α < 0.7` → marginal.
* `α < 0.4` → bottleneck; the breakeven curve is probably below 1×.

## Breakeven curve

```
S(α) = 1 + k × α  −  draftOverheadRatio × (1 + k)
```

Rendered with Recharts: the X axis is α from 0 to 1, the Y axis is theoretical speedup, the horizontal `y = 1` line is the "no-op" baseline. We mark the observed `(α, observed_speedup)` as a single dot. If the dot is below `y = 1`, the run is **slower than baseline** — turn off spec decoding.

Implementation lives in `src/lib/spec-bottlenecks.ts` and `src/components/spec-lab/BottleneckPanel.tsx`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://seekspeed.gitbook.io/seekspeed-docs/spec-lab/bottlenecks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
