Latency, Throughput and Time to First Token
A metrics collector and report renderer built on timestamp pairs, checked against numpy, two clocks and a queueing formula, and used on a small real server under open- and closed-loop load: what the clocks, the percentiles, the denominators and the load generator each do to the numbers.
One server, one model and one workload were measured with two kinds of load generator. At approximately 1.0 completed request per second, one client that waited for each answer before submitting another (closed loop) measured a 99th-percentile time to first token of 58 milliseconds. At an offered Poisson arrival rate of 1.0 request per second, a non-waiting open-loop client measured 1,477 milliseconds on the same server configuration and the same seeded workload. The achieved and offered rates are near one another, not identical definitions. At 2.9 requests a second the closed loop reported 1.0 seconds and the open loop 5.0. The critical controlled change was how requests arrived: sequentially after completions or independently of completions. Different arrival sequences and finite-run variability still matter, so the comparison demonstrates sensitivity to load generation rather than a universal 25-fold penalty.
That is the largest effect in the chapter and not the only one. The same decode loop took 28 to 32 milliseconds a token on the machine’s performance cores and 63 to 75 on its efficiency cores, and the operating system had put it on the second, so that one sweep of load runs ran at half speed for half its length. The first request after loading the model had a time to first token of 256 milliseconds against 38 for the next eleven. A throughput computed the way the chapter’s starter did it was 21.6 tokens a second for a server that delivered 12.4, and 0.6 for one that delivered 27.9. A p99 computed from fewer than 100 requests depends strongly on the estimator and on a handful of extreme observations; it is not the maximum under every percentile method. The collector’s existing p99_is_the_max flag overstates what the number means and needs a code correction. The mean of the p99 values of four consecutive segments was about 60 seconds while the p99 of the full run was about 90; a percentile of a union cannot be reconstructed by averaging segment percentiles.
The model is Qwen3-0.6B, the server is a queue and a decode loop that I wrote and that fits on a page, the load generator and server share one process, and no request crosses a network. The chapter’s plan asks for a reusable metrics collector and a report renderer, and for a gate that validates clocks, warm-ups and percentile arithmetic and keeps the denominators of prompt tokens and output tokens apart. These are all here, and each is checked against something that is not itself. No hosted provider was called. Results for throughput, queue delay and latency are from this deliberately small, single-machine serving experiment; published system results remain external evidence.
The question
A latency number is a difference of two instants, a throughput is a count over an interval, and a percentile is a rule applied to a sample. A report of “TTFT p99 1.5 s, 36 tokens a second” has not fixed any of the three, even before asking whether TTFT was measured at the server queue, the first decoded token, or the remote client. Which two instants? Which clock? Counted over what window, with which tokens in the numerator? Which estimator and confidence procedure, over how many independent runs and requests, sent by which arrival process at what offered and achieved rates? Names alone are not a comparison contract. A defensible report also records warm-up, failure handling, request lengths, sampling policy, CPU affinity, model and tokenizer versions, cache state, and the location of its clocks.
The questions for the chapter are therefore these. What does each metric measure when it is defined from timestamps? What can go wrong with the timestamps? What does each way of computing a percentile do to a small sample, and how do percentiles of several runs combine? What does a throughput divide by? And what does the load generator do to the answers? The chapter measures these questions with a fixed-length greedy output workload, not with variable-length real conversations; that choice removes termination variability and makes the queue the central object of study.
Where this sits
Prefill and Decode defined time to first token and time per output token as the cost of the two phases, and Memory Bandwidth and Compute Bottlenecks developed the memory-traffic cost of decoding; the particular small-model Python loop studied here is instead substantially CPU-launch-bound on this machine. Continuous Batching described continuous batching, which the server here does not have; it uses static batching, and the effect of that on the first token is part of what is measured. Reliability, Cancellation and Recovery motivated a terminal outcome for every request. Here the collector accepts an ok flag and records failure counts, but the experimental server normally completes its fixed-length work and is not a test of failure recovery. Reasoning Models and Inference-Time Compute and Tool Calling and Agentic Inference measured the time per token of this model on this machine, and Tool Calling and Agentic Inference modelled a task’s wait from it; this chapter measures waits with real queues.
Where the starter was wrong
The starter’s aggregate divides the total output tokens by the sum of the requests’ end-to-end latencies and calls the result throughput. That is a rate only if the requests ran one after another with no gaps. With idle time between requests the sum of service-plus-wait durations can be smaller than the measurement window; with concurrency or queues it can be much larger. Neither sum is the elapsed duration over which the server produced tokens. Below, on the same server, it is too high by 74% (21.6 against 12.4 tokens a second) at one load and too low by a factor of 46 (0.6 against 27.9) at another. It also takes TPOT as an input rather than deriving it from token timestamps, and reports a p99 of two requests without warning that the estimate is barely informative; it has no notion of a window, a clock, a warm-up, a failed request or an arrival process. Its percentile function is correct (linear interpolation, the same as numpy’s default) and is kept. The starter’s script and tests are left as they were. This chapter’s code is new.
The setup
The server. serving_lab.py runs Qwen3-0.6B (revision c1899de289a04d12100db370d81485cdf75e47ca, float16) behind a queue and a worker thread. When the worker is idle it takes up to max_batch waiting requests and serves them as one batch: it prefills them together, left-padded, and then decodes step by step, stamping each request’s token with time.perf_counter_ns() after a host read of the next token forces the relevant GPU result to be available. A completed sequence remains represented in the model’s tensor batch until the longest sequence finishes; its remaining tokens are generated but not counted as output for that request. This is the cost of this static-batch implementation, not a property of all batch schedulers. Decoding is greedy and the end-of-sequence tokens are suppressed, so every recorded request receives exactly its prescribed output length, even if an unconstrained conversation would have stopped early. A test checks that the loop’s tokens equal the library’s for prompts of different lengths on a small random Qwen3.
The workload. A prompt is one to six synthetic order messages (about 60 to 450 tokens); the output length is uniform from 16 to 48 tokens. Open-loop submissions follow seeded exponential interarrival times for a nominated Poisson rate, independently of response completions. Closed-loop submissions come from N client threads, each waiting for the preceding answer before submitting again; their achieved rate is an outcome, not a configured arrival rate. Each load cell records 140 requests; the first 10 in submission order are excluded from the collector and the remaining 130 are measured, after eight separately submitted warm-up requests. Dropping records does not remove any queueing interference caused by warm-up traffic; for these runs the warm-up completes first. The later load and closed-loop sweeps were run with the process pinned to performance-core logical CPUs; this must be checked rather than inferred merely from an affinity flag.
The records. Each request keeps scheduled (the instant the generator meant to send it, for open loop), submitted, one timestamp per output token, and finished, all in nanoseconds from one monotonic clock, with the prompt and output token counts. Request.validate checks the internal ordering and count invariants: scheduled-before-submitted when present, nondecreasing token timestamps after submission, output count equal to timestamp count, finish not before the last token, and a finished record when marked ok. These tests cannot detect timestamps consistently taken at the wrong instrumentation boundary, omitted failed requests, or a failure marked as successful.
The definitions. Each metric is a pair of timestamps or a count over a denominator, and the collector carries the definitions with it: For the measured requests here, finished is stamped when the final token is read by the host. A networked service would need separate client-observed submission, first-byte/token and terminal-event timestamps.
| Metric | Defined as |
|---|---|
| TTFT | first token minus submitted |
| TTFT from schedule | first token minus scheduled |
| ITL | gap between successive recorded tokens; pooled gaps weight longer requests more heavily |
| TPOT | (last recorded token minus first recorded token) / (output token count - 1), for requests with at least two tokens |
| E2E | finished minus submitted |
| E2E per output token | E2E divided by output tokens (a different quantity from TPOT, reported to show it) |
| request rate | completed requests divided by the window |
| output tokens per second | output tokens of completed requests divided by the window |
| prompt tokens per second | prompt tokens of completed requests divided by the window |
| goodput | successfully completed requests satisfying all specified per-request SLO limits, divided by the completed-request window |
| window | latest completion minus earliest submission among the measured successful requests; a completed-request observation window, not necessarily the configured arrival interval |
The vLLM benchmark documentation, as summarised for this chapter, defines TTFT as the time from sending a request to its first streamed output, measured at the client; ITL as the gaps between consecutive streamed outputs pooled over requests; and TPOT as (end-to-end latency minus TTFT) divided by (output tokens minus 1), which agrees with the table’s TPOT in this one-event-per-token, finished-on-last-token implementation. If events bundle several tokens or a terminal event trails the last token, equality requires further qualifications. Other throughput and goodput labels need separate definitions; they should never be transferred between tools by name alone. The vLLM tool measures at a streaming client; this laboratory measures at a queue/engine boundary. Matching formulas do not make those instrumentation points equivalent.
The SLO. For the goodput figures, a request meets the service level if its TTFT is at most 0.5 s and its TPOT is at most 60 ms, a limit fixed before the load runs, at about 1.8 times the unloaded time per output token. It is illustrative: no product asked for it. The SLO uses submitted-to-first-token TTFT and per-request TPOT; no end-to-end deadline or success-rate target is imposed. For a single-token response, TPOT is undefined and must not silently count as passing the SLO.
Validating the clocks
The clocks themselves. On this machine (Python 3.13, Windows 11), time.perf_counter and time.monotonic both use the Windows performance-counter facility and reported 100 ns nominal resolution and never went backwards in 200,000 consecutive reads each; time.time reads the precise system time at the same resolution, is adjustable (so can jump), and is not monotonic. time.process_time moves in steps of 15.625 ms: in 200,000 reads it had three distinct values. This observed CPU-time granularity makes it an unsuitable wall-latency clock for this loop, even though CPU process time can be useful for different profiling questions; a monotonic clock is the one for latency. The timed cost of reading perf_counter_ns was about 58 ns under this microbenchmark. Resolution, accuracy and overhead are different properties; none of these observations alone establishes clock synchronisation between hosts.
Sleeping is coarser than the clock. An open-loop generator waits until the instant a request is due. time.sleep(0.0005) took a median 1.01 ms (99th percentile 1.38); sleep(0.001) took 1.57 ms (1.98); sleep(0.005) took 5.52 ms (9.30, worst 12.1). The generator sleeps until near the deadline and then spins for the last two milliseconds. It records the positive lateness submitted - scheduled; the maximum observed in the reported runs was below 0.6 ms. Spinning reduces submission jitter here but consumes CPU, which can itself perturb a CPU-launch-bound server when the generator and engine share a process. The wrk2 project discusses the same load-generation and coordinated-omission hazards (about a millisecond from the operating system’s sleep) and gives the reason to record the scheduled time: it measures each latency from when the request was meant to be sent.
Two clocks agree. Every token of 30 single requests (711 gaps) was stamped on the monotonic counter and on the wall clock. The largest disagreement over one gap was 6.9 µs (median 0.3 µs), and over a request’s whole span 2.3 µs. The measured durations agree to a few microseconds on this host. This is a useful instrumentation cross-check, not independent proof of correct boundary placement: both are read inside the same process, and absolute wall-clock time can be adjusted.
Stamping asynchronous work. A GPU call returns to the host before the work is done. In the decode loop that does not matter here: the step is limited by launching its few hundred small kernels, and over 40 steps the host loop took 1.210 s and the GPU was finished at 1.211 s, so the measured difference between those placements was small (a step timed with a synchronise after it took 31.0 ms, and without one 30.3 and 30.5 ms). A call that the GPU limits is different. The prefill of eight prompts of 1,024 tokens returned to the host after 0.75 to 0.81 s and was finished on the GPU at 1.40 to 1.47 s, so timing host submission without waiting for completion underreported elapsed GPU work by about 45–46% in this setup. The loop stamps a token after reading it on the host, which waits; stamping immediately after launch rather than after the host read could measure enqueue progress instead of token readiness. For robust GPU benchmarking, synchronise at both appropriate timing boundaries or use correctly placed GPU events.
Which core. The same decode microbenchmark alternated CPU affinity settings while using the same GPU and process: unrestricted across 24 logical CPUs, restricted to performance-core threads (0–15), or restricted to efficiency cores (16–23). These are machine-specific logical CPU assignments, not a portable mapping:
| Placement | Milliseconds per decode step (six measurements) |
|---|---|
| all 24 logical CPUs | 62.3 to 68.7 |
| performance cores | 28.4 to 32.0 |
| efficiency cores | 62.6 to 75.1 |
The decode step is launch-bound, so it is a measure of how fast one CPU thread can issue small kernels, and on this hybrid processor the unrestricted result is consistent with the critical Python launch thread being scheduled on a slower core, though the measurements do not instrument each thread migration. The first sweep of load runs showed it: its third and fourth runs had a median time per output token of 66 ms against 33 ms in the first two, making the apparent serving capacity fall by roughly half in the discarded sweep. I stopped it, found the cause, and repeated the sweep pinned to the performance cores; the discarded sweep is in the evidence record. It also raises a question about earlier chapters, which reported steps of 84 to 91 ms on this machine on one day and about 30 on another, and which I attributed to the GPU being shared. I did not check whether it was this. The practical correction is to record CPU model, thread placement, affinity outcome, software versions and other GPU/CPU workloads with every run. GPU utilisation alone does not identify the bottleneck in a Python-driven kernel-launch loop.
Warm-up. In a fresh process, the first of twelve single requests of 16 output tokens had a TTFT of 256 ms and an end-to-end time of 743 ms. The next eleven had medians of 38 ms and 518 ms, and a second round of twelve 34 ms and 515 ms. The first request is consistent with one-time work such as allocator growth and library/kernel initialisation; those contributions were not isolated individually, an effect of seven times on the first token and 1.4 times on the whole request, and this particular first-request penalty was not visible in the subsequent observations. The later runs submit explicit warm-up traffic and exclude the first 10 recorded requests. Benchmark comparisons must use identical warm-up and cache policies; a warm model, a hot prefix cache and an already saturated queue are not interchangeable definitions of “warmed up.”
Percentiles
The arithmetic. percentile implements seven methods by name (linear, lower, higher, midpoint, nearest-rank, Hazen and Weibull) and was checked against numpy’s percentile with the corresponding method on random samples of sizes 1 to 250 at ten percentile levels each; within the scripted test set it agreed to nine decimal places. The labels are method choices, not different observations of the underlying latency distribution. The starter’s function is the first of them.
The method matters at small samples. The 99th percentile of the time to first token in the lightly loaded batch-1 run (130 requests) was 1.859 s by the lower method, 1.946 by the midpoint, 1.983 by linear interpolation, 2.034 by the higher method and by nearest-rank, 2.109 by Hazen’s and 2.292 by Weibull’s: approximately a 23% spread between the smallest and largest reported p99 values on identical requests (2.292/1.859 - 1). The median differed by 7% (0.216 to 0.231 s). The sample size, method, point estimate and uncertainty procedure all belong beside the reported tail. For a small run, none of these estimators is a precise measurement of a steady-state population p99.
The sample size. A small-sample correction. With fewer than 100 requests the empirical p99 is dominated by the final one or two order statistics, but it is not generally the maximum. For nearest_rank (the inverted empirical CDF), ceil(0.99 n) selects the maximum when n is below 100 (at n=100, its 99th ordered value is selected). For linear, an n=20 p99 lies 81% of the way from the second-largest to largest value, so it is smaller than the maximum unless they tie. The lower method can select the second-largest value. The current collector’s rule that sets p99_is_the_max for every method whenever n < 100 is therefore a known reporting bug, not evidence that those computed p99 values equal the maximum. For the busy batch-4 run (1.2 requests a second), the 99th percentile of the first 20 requests’ TTFT was 1.357 s (bootstrap interval 0.70 to 1.40; heavily determined by the sample maximum), of the first 50 1.405 s (1.17 to 1.41; still dominated by extreme observations), of the first 100 1.459 s (1.26 to 1.65) and of all 130 1.445 s (1.29 to 1.65). Even at 130 requests the interval is plus or minus 12%. The collector computes the interval with a bootstrap over requests, currently flags small samples with p99_is_the_max and prints “(= max)”. That marker must be changed to a method-aware small-sample warning, and tests should cover linear, lower, higher, midpoint, nearest_rank, Hazen and Weibull at 20, 50, 99 and 100 observations. The percentile bootstrap resamples individual requests as if independent and identically distributed. Queueing creates temporal dependence and non-stationarity, so the nominal 95% interval is not calibrated for these tails; its direction of error is not established without a dependent-resampling or repeated-run study.
Percentiles do not combine. Four consecutive parts of the saturated batch-1 run had 99th percentiles of 28.3, 51.8, 71.2 and 90.0 s. Their mean is 60.3 s. The 99th percentile of all 130 requests is 89.7 s. In a busy but stationary run the part percentiles were 1.330, 1.443, 1.543 and 1.349 s, their mean 1.416 and the whole 1.446: close, by luck of stationarity, but not a rule. What does combine, when bucket boundaries and accuracy settings agree, is a histogram of the underlying samples. LogHistogram buckets values geometrically with a stated relative error (here 1%), merges by adding counts, and estimates an order statistic with approximately that per-value relative-error tolerance for positive values at the chosen rank: the merged histograms gave 89.1 s and 1.419 s against exact 89.3 and 1.417. The implementation uses the lower order-statistic rank for its merged-sketch quantiles, whereas the chapter’s principal p99 tables use linear; comparisons must therefore specify the method, not attribute the entire discrepancy to histogram approximation. The unit tests exercise relative error on 5,000 lognormal samples and merging equivalence.
Throughput has a denominator
The collector reports three rates and names what each divides: request_rate_per_s, output_tokens_per_s and prompt_tokens_per_s, each dividing counts for completed measured requests by the interval from their earliest submission to their latest completion, with a test that no key is called merely “throughput” or “tokens_per_s”. Prompt and output tokens are separated because they cost different things: the prompt’s tokens are processed in one parallel pass, the output’s one at a time. Over the same window, the batch-4 server at 1.2 requests a second processed 187.8 prompt tokens and generated 36.5 output tokens a second. Adding 187.8 prompt and 36.5 output tokens per second into “224 tokens/s” would mix prefill work with autoregressive decode work, concealing a basic architectural difference. The defined rates are completed-request rates, not instantaneous device token rates, and the window includes both arrival gaps and queue drain.
The starter’s sum-of-latencies denominator versus the collector’s wall-time window on six load cells of this one server (output tokens per second; the workloads are the same seeded synthetic family):
| Run | Output tokens per second over the window | Starter’s formula |
|---|---|---|
| batch 1, offered 0.4 requests/s | 12.4 | 21.6 |
| batch 1, 0.8 | 24.5 | 7.8 |
| batch 1, 1.2 | 28.8 | 1.4 |
| batch 1, 2.5 | 27.9 | 0.6 |
| batch 4, 1.7 | 51.3 | 20.2 |
| batch 4, 3.6 | 88.8 | 4.2 |
At light load the server is idle between requests, the sum of latencies is shorter than the window, and the formula overstates. with overlapping or queued requests it can grow far larger and badly understate the rate. The direction depends on the actual arrival, service and wait patterns; it is not a universal monotonic rule. The test with four concurrent two-second requests gives the starter a quarter of the correct wall-window rate. This is why a throughput requires one common observation interval rather than a sum of individual latencies.
What load does to the numbers
Two configurations of the same server, maximum static batch sizes 1 and 4, were offered seeded Poisson arrivals at selected rates from 0.4 to 3.6 requests per second (not every rate was run for both). As a short finite-burst capacity calibration, 40 requests were submitted together after warm-up: batch 1 served 1.007 requests a second (31.0 output tokens a second), batch 4 served 3.213 (99.0). The four-way static-batch run delivered about 3.2 times the completed-request rate of the single-sequence configuration on this burst. These are not proved steady-state saturation capacities: admission, batch formation and the finite 40-request drain affect the calibration.
The open-loop results for max_batch=1 (130 measured completions per cell, with a 0.5 s TTFT / 60 ms TPOT SLO; confidence intervals are included only where supported by the saved table):
| Offered (req/s) | Achieved (req/s) | Output tok/s | TTFT p50 (s) | TTFT p99 (s), interval | TPOT p50 (ms) | E2E p99 (s) | Goodput (req/s), share meeting SLO |
|---|---|---|---|---|---|---|---|
| 0.4 | 0.40 | 12.4 | 0.22 | 1.98 (1.72 to 2.41) | 33.1 | 3.00 | 0.27 (67%) |
| 0.8 | 0.79 | 24.5 | 2.54 | 9.72 (7.97 to 10.84) | 34.3 | 11.3 | 0.11 (14%) |
| 1.2 | 0.93 | 28.8 | 25.9 | 33.4 | 33.2 | 34.5 | 0 |
| 1.8 | 0.92 | 28.8 | 41.0 | 66.6 | 33.0 | 67.9 | 0 |
| 2.5 | 0.90 | 27.9 | 53.9 | 90.7 | 33.6 | 92.2 | 0 |
For the same engine with max_batch=4 (the offered rate is a schedule parameter, and achieved throughput need not equal it):
| Offered (req/s) | Achieved (req/s) | Output tok/s | TTFT p50 (s) | TTFT p99 (s), interval | TPOT p50 (ms) | E2E p99 (s) | Goodput (req/s), share meeting SLO |
|---|---|---|---|---|---|---|---|
| 0.4 | 0.40 | 12.4 | 0.14 | 1.60 (1.16 to 1.77) | 33.2 | 2.66 | 0.29 (73%) |
| 1.0 | 0.98 | 30.6 | 0.37 | 1.48 (1.30 to 1.81) | 30.9 | 2.75 | 0.57 (58%) |
| 1.7 | 1.65 | 51.3 | 0.60 | 1.68 (1.45 to 1.95) | 29.1 | 2.72 | 0.66 (40%) |
| 2.5 | 2.42 | 75.3 | 1.08 | 3.13 (2.84 to 3.24) | 29.7 | 4.49 | 0.37 (15%) |
| 2.9 | 2.77 | 86.4 | 1.73 | 4.99 (4.65 to 5.82) | 29.0 | 6.00 | 0.17 (6%) |
| 3.6 | 2.85 | 88.8 | 7.58 | 10.13 (9.61 to 10.46) | 29.4 | 11.1 | 0 |
The two metrics see different things. The time per output token barely moved from the lightest load to the heaviest: 29 to 34 ms in every run, and the 99th percentile of inter-token gaps was 43 to 51 ms throughout. The time to first token went from 0.22 s to 54 s. For this fixed-length static decoder, inter-token service times remained fairly stable once a batch began, while TTFT included unbounded queue wait as offered load approached or exceeded service capacity. A dashboard monitoring only TPOT would miss overload. Monitor TTFT, queue age/depth, end-to-end completion, failure and SLO goodput together; pooled ITL and per-request TPOT also weight requests differently.
The median hides the tail. At 0.4 requests a second the batch-1 server was busy 42% of the time. The median first token took 0.22 s and the 99th percentile 1.98 s, nine times as long, because new arrivals can encounter a request already in service plus queued work, and Poisson arrivals can bunch. The delay is not bounded by one service time if other requests are ahead. At 0.8 requests per second (approximately 87% estimated utilisation), the p99-to-median ratio was 3.8 and both values were already measured in seconds. The utilisation estimates come from reconstructed service times, not a separate GPU-utilisation meter.
Throughput saturates and latency does not. Both servers’ output rates climbed with the offered rate and then flattened at their capacity (about 29 tokens a second for batch 1, about 89 for batch 4) while queue-driven TTFT and end-to-end latency grew sharply. At the saturated batch-1 rates the median first token waited 26 to 54 seconds; the achieved request rate was 0.90 to 0.93 against an offered 1.2 to 2.5. Once offered load exceeds sustainable capacity, the finite run is intrinsically transient: backlog grows during submissions and drains afterward. Its observed p99 depends strongly on run length, arrival seed and whether the drain is included; it is not a steady-state latency percentile.
Goodput peaks before capacity. For the batch-4 server the throughput in requests kept rising to 2.85 a second, but the number of requests meeting the SLO a second peaked at 0.66 with 1.7 offered (at 1.7 offered requests/s, about 53% of the short-burst batch-4 calibration rate) and then fell to 0.37, 0.17 and 0. This is the shape that motivates goodput as a metric. The DistServe paper uses goodput under TTFT and TPOT constraints as a serving objective, and its authors report that disaggregating prefill and decode serves up to 7.4 times more requests within the constraints. The curve here is for this server and this arbitrary SLO, shows that this particular SLO-qualified completion rate peaks below the highest observed raw throughput, and is not a reproduction of the paper.
Static batching and the first token. At 0.4 requests a second the batch-4 server’s median TTFT (0.14 s) was lower than the batch-1 server’s (0.22 s), but the mechanism is not identified by these runs: arrival phasing, workload randomness, batching opportunities and cache/warm-up history are alternative explanations. At 2.5 requests a second its median was 1.08 s: a request arriving during an executing static batch waits for that entire batch to finish before admission, and a 48-token request can take around 1.4 s of decoding on this setup. The Engine also has an optional max_wait_s admission delay, set to zero for these runs. Continuous Batching’s engine, and the chunked prefill and stall-free scheduling of the Sarathi-Serve paper (which reports 2.6 times the serving capacity of vLLM for Mistral-7B on one A100, a figure I did not reproduce), are about that wait. This server has none of it, and the measurements establish neither their speedups nor their scheduling mechanisms.
A check on the queue. For a stable, stationary M/G/1 queue with Poisson arrivals, one FIFO server, independent service times and utilisation below one, the Pollaczek–Khinchine relation predicts the mean queue wait as λ E[S²] / (2(1−λE[S])). This is a theoretical comparator, not an identity for a finite warm-started run. Here service starts and durations are reconstructed from submission and finish records under the one-at-a-time FIFO assumption, rather than stamped independently at worker admission. At 42% utilisation the formula gave a mean wait of 0.429 s and the records 0.373 s. At 87% it gave 4.16 s and the records 2.91 s. A mean over 130 requests of a queue that starts empty is itself uncertain, so I simulated 2,000 such runs from the measured service times: the 5th to 95th percentile of their means was 0.26 to 0.68 s at the first load and 1.31 to 7.39 s at the second, with the measured values inside both. The measured means fall within the range of these finite-run simulations, but that does not validate the tail quantiles or prove stationarity; the same sample of reconstructed service durations also informs the simulation. This is the check that tests the wait times against something independent; a check by Little’s law, which I tried first, tests nothing here, because using the same submission/finish records to compute both sides can turn it into a bookkeeping identity rather than an independent test of service dynamics.
Open loop and closed loop
A closed-loop client sends its next request only when it has the previous answer. When the server slows, a fixed population of synchronous clients slows its offered submissions; it cannot build the same unbounded queue as an independently scheduled arrival stream. This makes it unsuitable as a substitute for the latency distribution seen under open arrival traffic. Gil Tene’s wrk2 README names this coordinated omission and addresses this source of coordinated omission through constant-rate scheduling and scheduled-time latency accounting. This chapter’s Poisson open loop is independent of completions but is not the constant-interval wrk2 schedule. It records both submission-based TTFT and scheduled-time TTFT; their near equality in these runs reflects minimal generator lateness, not a general property of open load generators. The vLLM documentation, as summarised, describes a request rate that follows a Poisson process by default and a separate cap on outstanding requests; it does not use the terms.
The same batch-4 server and workload, closed loop at 1, 2, 4 and 8 clients, and open loop at nearby offered Poisson rates (1.0, 1.7 and 2.9/s) rather than at an exactly matched achieved rate; the eight-client case has no separately measured open-loop counterpart:
| Clients | Closed-loop rate (req/s) | Closed: TTFT p50, p99 (s) | Open loop at that rate: TTFT p50, p99 (s) | Closed: E2E p99 (s) | Open: E2E p99 (s) |
|---|---|---|---|---|---|
| 1 | 1.00 | 0.036, 0.058 | 0.371, 1.477 | 1.58 | 2.75 |
| 2 | 1.74 | 0.072, 0.914 | 0.600, 1.685 | 2.09 | 2.72 |
| 4 | 2.93 | 0.390, 1.021 | 1.729, 4.995 | 2.17 | 6.00 |
| 8 | 2.72 | 1.808, 2.489 | (not run at this rate) | 3.65 |
At approximately matched rates, closed-loop p99 TTFT was about 1.8–25 times smaller for the three paired comparisons, with one finite run per condition. These are different arrival processes, not an estimate of how much faster the engine became. With one synchronous client, at most one request is outstanding, so there is no queue of that client’s other requests and first-token latency largely excludes service contention from additional demand. That is a true measurement of a different thing, the latency of a user who waits for the answer before asking again, and it is not the latency a service sees from independent users who arrive when they arrive. Both describe legitimate but different workload contracts. Comparing them without the arrival schedule, concurrency, offered and achieved rates, and window definition is the benchmarking error.
A report that can be compared
render_report produces the document in research/ch36/report_example.md from a summary and a description of the workload and the environment. Given supplied environment and workload metadata, it prints: the environment; the workload (including whatever arrival process, rate and length distributions the caller provided); how many requests were sent, how many were dropped as warm-up, how many were measured, completed and failed; the window; the percentile method; for each available latency metric the count, mean, 50th, 90th, 95th and 99th percentile, a request-bootstrap interval where computed, and the maximum; each throughput with its denominator, and the offered rate from the schedule; goodput with the limits; and the definition of every metric as a pair of timestamps. The tests check presence and named denominators. The report currently repeats the method-independent (= max) annotation for small p99 samples; that must become an honest method-aware warning. Metadata entries are passed in, not automatically collected, and the report cannot validate the truth of caller-supplied platform or workload details.
Two publication requirements are not yet first-class fields in the report: precisely where its timestamps were taken (in the example, at the boundary between a queue and an engine in one process, so it includes no network, no tokeniser service and no HTTP framing), and it does not say which core ran the loop. and which logical CPU the launch thread actually ran on. Both must be recorded explicitly in the supplied environment and instrumentation contract, together with the result of the affinity call; render_report does not infer either. A networked benchmark should additionally identify the streaming endpoint and client timestamp implementation.
What the numbers do not show
The server is a toy. Static batching, a Python loop, a model of 0.6 billion parameters, outputs of 16 to 48 tokens and prompts to 450. The mechanisms behind throughput saturation, growing queues and coordinated omission extend beyond this example, but even the shape of a specific curve can change with scheduler, request-length distribution, arrival process and SLO. Neither the particular numbers nor this apparent goodput peak should be extrapolated directly to production.
The client is in the process. There is no network and no HTTP, so the timestamps cover submission to the in-process queue, worker execution and host-visible tokens. They exclude network transport, TLS/HTTP framing, server-side tokenisation, proxy buffering and remote client rendering. The same numerical TTFT label on a provider dashboard is therefore not necessarily comparable.
One run per cell. Each point is a single 130-request run with one seed for the arrivals. The listed intervals are naive request-bootstrap intervals, not a full account of 130-request tail uncertainty under a time-dependent queue. and the queueing check shows the means are consistent with theory, Different arrival seeds, repeated full runs or longer steady-state windows could yield different tails. The sweep was not independently repeated, and the saturated cells were intentionally transient.
The SLO is arbitrary. The goodput figures are for 0.5 s and 60 ms, set before the runs. The peak of the curve depends on them. Changing either threshold can move the rate at which goodput peaks, so the table should not be read as a benchmark ranking independent of the service-level contract.
The machine was not quiet. The GPU is shared with a desktop and other programs. Pinning the process addressed the largest identified source of variation. It does not guarantee that model execution, memory pressure, thermal state, background work or GPU clocks stayed fixed, and no exhaustive noise study was performed.
The literature is not reproduced. DistServe’s and Sarathi-Serve’s gains are their authors’, on their hardware and workloads, as read in their abstracts; vLLM’s benchmark tool was not run. Two directly related publications that strengthen the measurement argument—Dean and Barroso on tail latency, and Masson, Rim and Lee on mergeable relative-error quantile sketches—are added below as background, not as reproduced results.
Inference Lab increment
examples/ch36/metrics_core.py adds request-record validation, seven explicit percentile estimators, request-bootstrap intervals, a mergeable log-bucket quantile sketch, the summary and report renderer, and clock probes. Known issue: spread sets p99_is_the_max from sample size alone; it must instead report which order statistic/interpolation was used and warn on small tail samples without asserting equality to the maximum.
examples/ch36/serving_lab.py adds the server (Job, serve_batch, Engine), the workload and the load generators (make_workload, poisson_offsets, run_open, run_closed), set_affinity, and the commands clocks, clockcheck, affinity, gpusync, warmup, calibrate, load and closed. The server does not provide HTTP, streaming-event semantics across a network, request cancellation or dynamic batch membership; its measured tokens are host-visible GPU output tokens.
examples/ch36/serving_analysis.py adds analyse_load, analyse_closed, open_vs_closed, starter_throughput, fifo_service_times, pollaczek_khinchine, simulate_fifo, percentile_methods and merge_demo. Its M/G/1 theory check assumes independent stationary service durations; the raw records do not establish those conditions.
To rebuild the existing analyses and example report from saved run artifacts, without claiming new model execution:
python research/ch36/build_results.py
To run a fresh load sweep on a compatible GPU host (requires the local model, Python dependencies and valid Windows CPU-affinity mapping; this was not rerun for this editorial revision):
python examples/ch36/serving_lab.py load --pin FFFF --rates 0.4,0.8,1.2,1.8,2.5 --batches 1,4
The rule this adds: define every metric as a pair of timestamps or a count over a named denominator, record the clock and where it ran, send load on a schedule that does not wait for the server, report quantiles with their estimator, sample size, correct small-sample diagnostics and uncertainty limitations, and compare systems at matched workload and meaningful SLO-qualified goodput, not merely the load where raw throughput peaks.
What you should now be able to do
- Define TTFT, ITL, TPOT, end-to-end latency, request rate, prompt-token rate, output-token rate and SLO goodput from exact timestamps and denominators; distinguish pooled gaps from per-request token time.
- Select and probe an appropriate monotonic clock; explain why clock resolution, elapsed GPU completion, timestamp placement and cross-host synchronisation are distinct.
- Measure asynchronous GPU execution with completion-aware timestamps or GPU events, and identify which CPU thread drives a launch-bound model.
- Compute a named percentile estimator and check it against NumPy; explain why a small-sample p99 is not necessarily the maximum and why an ordinary request bootstrap may not describe queue-dependent uncertainty.
- Combine raw observations or compatible mergeable histograms, never by averaging percentiles; distinguish quantile sketch relative value error from estimation error.
- Define a completed-request measurement window and separate output-token throughput from prompt-token throughput, scheduled offered rate and successfully completed request rate.
- Explain coordinated omission, and design open-loop and closed-loop experiments whose different arrival processes are reported rather than silently conflated.
- Read an open-loop load curve for the throughput knee, queue-driven TTFT growth, stable post-first-token decode times and SLO-dependent goodput; distinguish transient overload from a stationary serving regime.
Key terms
- TTFT: time from the specified start boundary to the first observable output token; in this lab, first host-visible token minus queue submission.
- ITL: inter-token latency, a gap between successive output events; pooled ITL gives requests with more emitted tokens more weight.
- TPOT: for a request with at least two tokens, the time from first to last token divided by output token count minus one.
- Window: the explicit interval over which completed-request rates are calculated; here earliest measured successful submission to latest measured successful completion.
- Goodput: successfully completed requests satisfying every stated per-request SLO limit per unit of the named window.
- Open loop: requests submitted by a schedule that does not wait for preceding responses; here, a seeded Poisson process.
- Closed loop: a fixed number of clients submitting the next request after the previous response, with achieved rate controlled partly by service time.
- Coordinated omission: sampling or reporting that under-represents slow periods because arrivals stop or are delayed when the service is slow.
- Mergeable histogram: a compact summary built from compatible bins that can be merged before computing approximate quantiles; bin-value precision is not sampling confidence.
- Tail estimator: an explicitly named convention for mapping finite ordered observations to a percentile, including interpolation or nearest rank.
Reader exercises
- Put the same engine behind an actual streaming HTTP endpoint and measure TTFT/ITL/E2E from a separate process; record both server and client timestamps and distinguish framing from model work.
- Replace static batching with continuous batching and repeat matched-load experiments with identical prompt/output distributions and warm-up policy.
- Repeat the 130-request batch-4 sweep with independent seeds, then with longer stationary runs below capacity. Compare point estimates, between-run spread and block-bootstrap or replicated-run intervals for p99.
- Choose separate TTFT/TPOT SLOs for an interactive chat product and an asynchronous batch product, then compare goodput-rate curves with the same arrival process.
- Add chunked prefill and record the tail ITL of requests already decoding, not only the TTFT of new arrivals.
- Run the CPU-affinity experiment on another host. Record the actual logical core and success/failure of the affinity call, and identify whether launch-bound behaviour persists.
- Repair
p99_is_the_max: test all seven estimators on 20, 50, 99, 100 and 130-element samples, and make the renderer display a method-aware tail warning rather than a false equality with the maximum. - Write a comparison gate that rejects reports with incompatible instrumentation boundaries, windows, warm-ups, percentile methods, failure denominators, offered-load schedules or output-length policies.
- Add a controlled test where a load-generator thread misses scheduled send times by tens of milliseconds; report submission-time and scheduled-time TTFT and their different interpretations.
- Calibrate the batch server with a longer steady-state arrival stream and record actual service-start timestamps, queue depth and thread placement. Check the assumptions behind the M/G/1 approximation before treating its prediction as independent validation.
References
- DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving — Zhong et al.; arXiv 2401.09670, v1 18 January 2024, v3 6 June 2024; OSDI 2024 per the arXiv listing; abstract read on 23 October 2026; the reported gains (up to 7.4 times more requests or a 12.6 times tighter SLO) are the authors’ and were not reproduced.
- Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve — Agrawal et al.; OSDI ‘24, pages 117 to 134; abstract read on 23 October 2026; the reported capacity gains over vLLM are the authors’, for their models and hardware, and were not reproduced.
- vLLM Benchmark CLI — official documentation of a live project; undated; read on 23 October 2026 through a page-fetch summary; the version of vLLM was not recorded and vLLM was not run.
- wrk2 — Gil Tene; README read on 23 October 2026 through a page-fetch summary, for the description of coordinated omission; not run.
- Qwen3-0.6B — the model used; Apache-2.0; revision
c1899de289a04d12100db370d81485cdf75e47ca. - DDSketch: A Fast and Fully-Mergeable Quantile Sketch with Relative-Error Guarantees — Masson, Rim and Lee; Proceedings of the VLDB Endowment 12(12), 2019. Establishes why relative-value error and mergeability are appropriate for distributed latency quantiles. This chapter implements a small, DDSketch-style logarithmic histogram; it does not reproduce the paper’s resource or accuracy benchmarks.
- The Tail at Scale — Dean and Barroso; Communications of the ACM 56(2), 2013. Background on how latency variability and multi-stage systems amplify tail risk; not reproduced by the single-process queue here. The chapter’s measurements concern one model and one worker, not a fan-out service.
Evidence in this chapter
| Claim | Category |
|---|---|
perf_counter and monotonic read the performance counter at 100 ns and never went backwards in 200,000 reads; process_time moves in steps of 15.625 ms |
Book result (Python 3.13, Windows 11) |
| Two clocks gave per-gap durations that agree to 6.9 µs at most over 711 gaps | Book result |
| Not synchronising the GPU changed nothing in the launch-bound decode loop and shortened a GPU-bound prefill by 45 to 46% | Book result |
| The same decode loop took 28 to 32 ms a step on the performance cores and 63 to 75 ms on the efficiency cores, and defaulted to the latter on the day | Book result (one machine) |
| The first request after loading had a TTFT of 256 ms against a median of 38 ms for the next eleven | Book result |
Seven named percentile estimators matched NumPy on the tested samples; at 130 requests their p99 values differed by about 23%. The manuscript previously misstated that p99 is the maximum for all methods below 100 samples; p99_is_the_max uses that incorrect method-independent rule |
Book result for conformance and method spread; identified collector/reporting defect |
| The mean of four parts’ 99th percentiles was 60.3 s against 89.7 s for the whole; merged histograms gave 89.1 s | Book result |
| The starter’s throughput formula was 74% too high at one load and 46 times too low at another | Book result |
| TPOT stayed at 29 to 34 ms from the lightest load to the heaviest while median TTFT went from 0.22 s to 54 s | Book result (one run per cell) |
| Goodput under a 0.5 s and 60 ms SLO peaked at 0.66 requests/s with about half of the batch-4 server’s measured capacity offered | Book result for an illustrative SLO |
| Measured FIFO mean waits were inside the finite-run simulation ranges and near M/G/1 theoretical predictions at about 42% and 87% reconstructed utilisation; simulations reused the observed service-time distribution | Book result with stationarity/independence assumptions, not an independent verification of tail latency |
| At approximately matched offered/achieved rates, the closed-loop p99 TTFT was 1.8–25 times smaller in three single-run comparisons of different arrival processes | Book result; not a causal speedup of the serving engine |
| Metric definitions of vLLM’s benchmark; coordinated omission; goodput and the gains of DistServe and Sarathi-Serve | Reported by the sources; not reproduced |
| Any serving engine, a network client, continuous batching, other models or hardware | NOT_RUN |
The histogram merges and approximates lower-method order statistics with bounded relative value error; combining its output directly with interpolated linear p99 includes an estimator mismatch |
Book implementation/property, demonstrated on synthetic values; theoretical context from DDSketch (2019) |
| The test server excludes HTTP, tokeniser-service overhead and remote client network latency | Scope limitation, NOT_RUN |
Implementation status
- Manuscript:
content/books/inference/36-chapter.md - Runnable examples:
examples/ch36/metrics.py(original, unchanged),examples/ch36/metrics_core.py(collector, percentiles, histogram, summary, report),examples/ch36/serving_lab.py(server, load generators, experiments),examples/ch36/serving_analysis.py(analyses) - Tests:
tests/test_ch36_metrics.py(original),tests/test_ch36_metrics_lab.py(28 reported tests, including percentile-method comparisons against NumPy, the histogram’s error bound and its merge, the definitions on hand-built records, refusal of records that cannot be right, the summary’s window, warm-up, failures, goodput, denominators and current small-sample flag (which needs the method-specific correction above), the starter’s formula under concurrency, the clock probe, the queueing formula against a long simulation, the report’s contents, and the batched decode loop against the library for prompts of different lengths) - Evidence:
research/ch36/sources.md,research/ch36/results.json,research/ch36/report_example.md,research/ch36/raw/(every request of every run, with every token’s timestamp),research/ch36/measurements/,research/ch36/build_results.py,research/evidence-register.md - Verification command:
python -m unittest discover -s tests -v(the chapter’s existing verification instruction; tests were not rerun for this manuscript edit)
The chapter is a draft with draft = false. It makes no claim about hosted services, about serving engines, or about hardware other than this machine. Cost per Million Tokens turns to cost. Publication gate: correct the p99 small-sample flag and its regression tests, record the exact timing boundary and affinity outcome in the report, and repeat at least one open-versus-closed comparison with independent arrival seeds before treating the reported tail-ratio magnitude as stable.