Section 18.1.9

ECDF and reading a cumulative latency curve

Full name: Empirical cumulative distribution function (ECDF) and reading a cumulative latency curve.

Definition

A latency ECDF (empirical cumulative distribution function §11.17 of measured latencies) is a curve whose height above each duration tt on the horizontal axis is the fraction of measured requests whose latency is at most tt. Latency is the time from a request’s start to its completion. Read upward from a deadline tt, the curve gives the fraction of requests that finished by tt. For a level above zero and at most one, read across from a height pp, it gives the sample quantile §11.16 at level pp: the shortest measured latency within which at least that fraction finished.

Where it fits

Main entry: Empirical cumulative distribution function (ECDF) (§11.17).

The ECDF entry explains the construction: a staircase that rises by 1/n1/n at each of the nn measured values. This entry is about comparing two such curves. At a fixed duration tt, the system with the higher curve finished a larger fraction of its requests within tt, so more of its measured requests finished by that deadline. If curve A is at least as high as curve B at every duration, A is at least as good for every deadline, and each percentile of A is at most the matching percentile of B; statisticians then call the empirical latency distribution §11.36 of A stochastically smaller than that of B. Population dominance requires evidence beyond this sample.

When the curves cross, the better system depends on the deadline. Let system A have invented latencies of 2, 2, 4 and 10 milliseconds (ms) and system B have 1, 5, 5 and 5 ms. At 3 ms, A has finished 2/4=0.52 / 4 = 0.5 of its requests and B 1/4=0.251 / 4 = 0.25. At 5 ms, A has finished 3/4=0.753 / 4 = 0.75 and B 4/4=14 / 4 = 1. One-number summaries disagree as well: read across at height 0.5, A has the lower median §11.13, 2 ms against 5 ms, while B has the lower mean, 16/4=416 / 4 = 4 ms against 18/4=4.518 / 4 = 4.5 ms.

A logarithmic horizontal axis, on which equal distances stand for equal ratios of time, changes only the horizontal spacing. The heights, the durations at which the curves cross and the order of the curves at each duration stay the same. The entry on logarithmic axes and multiplicative differences §18.1.12 explains such axes.

Limits and common mistakes

Rank two curves only when they measure the same thing: the same start and end events, the same workload and the same kind of request. Even then, a gap describes a difference between the observed samples. Sampling variation or a difference in operating conditions can also separate the curves.

The heights are fractions of the measured requests, not guarantees about future ones. With four requests per system, one request moves a curve by 0.25, so a small gap can be chance.

Choose the denominator to match the question. To plot the fraction of all submitted requests that completed by each deadline, retain failures and timeouts §9.34 in that denominator. Suppose nine of ten completed by 50 ms and the last was still running when observation ended. At 50 ms the fraction is 9/10=0.99/10 = 0.9; after 50 ms its eventual completion is unknown. If the last request was canceled permanently, record that outcome as a failure to complete. An ECDF over the nine completed durations instead describes latency conditional on completion.

Questions answered

Which of two latency ECDFs is preferable?

The latency ECDF (empirical cumulative distribution function) that lies higher is preferable at each deadline where it is higher, because its height at a duration is the fraction of measured requests that finished within that duration. One curve is preferable outright only if it is at least as high as the other at every duration.

If the curves cross, neither is better at every deadline, and the comparison needs a criterion fixed in advance, such as a deadline or a percentile. With latencies of 2, 2, 4 and 10 milliseconds for system A and 1, 5, 5 and 5 milliseconds for system B, A has finished a larger fraction of its requests by 3 milliseconds (0.5 against 0.25), but B has finished a larger fraction by 5 milliseconds (1 against 0.75).

Related entries: Quantile and percentile (§11.16), Confidence interval (§11.18), Matplotlib (§12.30), Censoring (§11.28), Latency distribution and tail (§11.36).