Definition
Warmup is the first part of a run, in which a system’s behavior keeps changing because its internal state is still being built: connections open, caches (small fast memories for recently used data) fill and code may be compiled. Steady state is the regime that follows, in which the measured outcome’s distribution, how often each value occurs, stops changing with time. A measurement that excludes warmup describes a long-running system; one that includes it describes starting up. The rule that separates them must be fixed before the outcomes are examined.
The idea
A client sends requests to a server. The first request must open a network connection, which takes 50 milliseconds, and every request then takes 2 milliseconds over the open connection. A user who sends one request and leaves waits milliseconds. A program that keeps the connection open for hours sees 2 milliseconds per request. Both numbers are true. They describe different phases of the system’s life, and an average that mixes the phases in an arbitrary proportion describes neither. Because the two phases can rank two versions differently, the rule that separates them must be fixed before the results are seen.
A car’s fuel consumption is a fair picture. A cold engine uses more fuel for the first few kilometers, so a short trip and a long motorway drive have different averages, and the trip in question decides which average to report. The picture stops being accurate in one respect. A car engine reliably reaches the same warm state. A computer system may take a different time to warm up in every run, may settle into a different state in different runs, or may never settle at all, because a queue, a log or a memory leak §4.8 keeps growing.
How it works
Treat the warmup decision as part of the estimand §11.2, the quantity the measurement is meant to estimate.
Name the phase of interest. A cold start is the first operation after a defined reset. A session is a fixed number of operations that begins at that reset. Steady state is the behavior after warmup has ended.
List the state that persists between operations, and say how each part is reset for a cold start: open connections, the contents of data and instruction caches, code compiled while the program runs, memory pools, file contents that the operating system keeps in memory, the processor’s clock frequency, which power management changes with load, and the processor’s temperature.
Fix the warmup rule before the measured outcomes are examined, and apply the same rule to every version being compared. Three kinds of rule are common. A fixed count discards the first operations, with justified by the mechanism, for example the number of operations needed to open every connection and touch every buffer. A pilot run is a separate run used only to choose ; its data are then set aside. A detection rule is applied mechanically to each run, such as the MSER (marginal standard error §11.15 rule) described below, or a changepoint method, a statistical procedure that locates the points at which the distribution of a series shifts.
Keep the warmup observations. Store them, and report them as the cold-start result whenever users pay that cost.
Check that the retained part is steady. Compare its first half with its second half: in the mean, in a high percentile §11.16, and in resources such as memory in use and queue length.
MSER chooses the number of discarded operations that makes the estimated standard error of the mean of the remaining operations smallest; the standard error is the typical size of the error of a sample mean §11.12. Discarding early values removes their pull on the mean but leaves fewer values to average, and MSER picks the cutoff at which this trade-off is best.
Worked example
A comparison that reverses. Version A costs 50 milliseconds to set up and 2 milliseconds per request, so a session of requests averages milliseconds per request: the setup cost does not disappear in long sessions; it is spread over more requests. Version B costs 10 milliseconds to set up and 3 milliseconds per request. A session of 10 requests takes milliseconds on A and milliseconds on B, so B is faster. With the first request discarded as warmup, the remaining 9 requests average 2 milliseconds each on A and 3 on B, so A is faster. Both results are correct, for different questions. A session of requests costs the same on both versions when , that is, when . For shorter sessions B wins; for longer sessions A wins.
A detection rule applied to one run. A run produced six durations, in milliseconds: 7, 4, 2, 3, 2, 3. For each candidate from 0 to , keep the values after the first , compute their mean, the sum of their squared deviations from that mean, and .
: mean ; deviations 3.5, 0.5, , , , ; ; .
: values 4, 2, 3, 2, 3, mean ; deviations 1.2, , 0.2, , 0.2; ; .
: values 2, 3, 2, 3, mean 2.5, each 0.5 away from it; ; .
: values 3, 2, 3, mean ; deviations , , ; ; .
The smallest value is at : the rule discards the 7 and the 4 as warmup, and the steady-state estimate is the mean of the other four values, 2.5 milliseconds. The rule was fixed in advance and runs mechanically, so no choice was made after the outcomes were seen.
Stated precisely
Let be the outcomes of the operations of one run, in the order in which they occurred. The run is in steady state from operation onwards if the sequence is stationary: shifting it in time does not change its probabilities. Formally, for every , all indices and every shift , the values have the same joint distribution as . The first operations are the warmup, and is called the truncation point.
Stationarity implies that every with has the same distribution. The steady-state mean , where denotes the expected value (the probability-weighted average), is therefore one number, and the sample mean of estimates it. Stationarity does not imply independence. Consecutive operations often influence each other, for example through a shared queue, so steady-state values share one distribution but are often not independent, and therefore not independent and identically distributed §11.5. A standard error computed as if they were independent is too small when consecutive values are positively correlated, which is the common case.
Other phases have their own estimands. The cold-start estimand is over runs that begin in the defined reset state. The estimand for a session of operations is .
MSER chooses where means the value of that makes the expression smallest. The expression equals , where is the variance §11.14 of the retained values computed with divisor ; this is the squared standard error of their mean if they were independent. The search covers only the first half of the run, because a cutoff near the end leaves too few values for the expression to be stable.
A truncation point is a valid analysis choice when it follows from a rule fixed before the compared outcomes were seen and applied in the same way to every version. A cutoff chosen by inspecting the comparison makes the reported difference the most favorable of several that were tried, which overstates it.
Limits and common mistakes
A fixed discarded prefix is a rule, not a proof. Discarding 100 operations does not show that operation 101 is in steady state; the check in step 5 of How it works must still be made.
Some systems never reach steady state. A memory leak, a log that fills its storage, a queue that grows because work arrives faster than it is served, and a processor that slows down as it heats up all make behavior drift for the whole run. A 2017 study of language virtual machines §2.3, which compile the busiest parts of a program to machine code while it runs (Barrett and colleagues, “Virtual Machine Warmup Blows Hot and Cold”), found that many benchmark runs never reached a steady state of peak performance, and that some became slower over time [478]. Report such drift as a result; do not cut it away. A steady mean can also hide a drifting tail or a growing use of memory.
Different versions can need different warmup lengths. A fixed count chosen for one version can cut another version’s warmup short and make that version look slower. Use a criterion applied to each version, or justify the count for each version from its mechanism.
Warm state carries over between runs that are not reset. If runs of version A always follow runs of version B on the same machine, A inherits caches that B warmed, and the effect of the order is mixed with the effect of the version, which is confounding §11.10. Reset the state between runs, or decide the order by randomization §11.8.
Excluding warmup is wrong when users pay it. A device that restarts often, a program that is started for every request, or a short session spends much of its life in warmup.
Questions answered
Was warmup exclusion decided before examining the outcome?
A warmup exclusion can be trusted only if the rule that decides which operations count as warmup was fixed and recorded before the outcomes it affects were examined, and was applied in the same way to every version compared. Warmup is the early part of a run in which caches, connections and other state are still being built, so its operations are slower than, or different from, those of the later steady state. Whether warmup is included can reverse a comparison: a version with an expensive setup and cheap operations loses short sessions and wins long ones. An analyst who chooses the cutoff after seeing the results can therefore move it until the preferred version wins.
To check, look for a dated analysis plan §13.17, a description of the analysis written before the data were examined, that states the rule and its reason: the question asked (cold start, session or long-running service) or the mechanism that makes early operations different. Confirm that the discarded operations were kept and reported, not deleted. If the rule was chosen afterwards, label the result exploratory, show it for several cutoffs as a sensitivity analysis §11.46, and confirm it on new runs with the cutoff fixed.
Related entries: Estimand and estimator (§11.2), Independent and identically distributed samples (§11.5), Outlier handling (§11.31), Analysis plan (§13.17), Sensitivity analysis (§11.46). Further reading: [478].