Skip to main content

Proxy benchmarking · part 1 of 2

How to benchmark a proxy's CPU when the noise is bigger than the effect

By Otto van der Schaaf, We-Amp ·

If your CI has a performance gate, it has a smallest regression it can resolve, and a number of runs that resolution costs. Many gates do not know either number. On our test server, one A/B run of an Envoy build against another cannot tell a 2% CPU change from no change or from a 4% one; 12 paired rounds can. A gate set at 1% will flap; a gate set at 3% will pass most 2% regressions.

Many of the changes we have priced move Envoy’s CPU per request by 1% to 5%, and a single-run benchmark on our server cannot see that range. This series is the method we use to get past that, built while pricing Envoy’s settings, filters and builds (Envoy performance, measured). The author is an emeritus maintainer of Nighthawk, the load generator it uses.

This first post covers the ideas. The next one shows the fast loop we built on top of them, and how we checked it before trusting it.

Key points

  • One A/B run per commit cannot gate at 1%. With about 1% spread per round, 12 paired rounds resolve about 2% on our server, once the difference between sessions is counted (Modelled from our measured spreads).
  • Most of the noise depends on what you compare. Two windows inside one Envoy process differ by 0.04% (one standard deviation). Two separate processes differ by about 1%. Each session’s result also carries its own offset of about 0.34% (one standard deviation), so two sessions differ by about 0.48%.
  • An A/A run sets the smallest number worth reporting. The same binary against itself, in the same session, shows what the rig cannot tell apart: about 1.2% on HTTP/1 proxied responses in one session (0.7% to 1.7% in another, by shape and load), 1.9% on HTTP/2.
  • The plan comes before the data. Rows, arms, rounds, kill lines and the A/A floor are written down and reviewed before the first measurement. Anything chosen afterwards is labelled Exploratory. Our first calibration of the fast loop failed its own gate, and that result stands as recorded.
  • Every number carries a basis label: Measured, No verdict, Not resolved, Exploratory or Modelled. Only Measured numbers become prices.
  • A fast loop screens ideas and decides nothing. It is checked against slow restart-paired runs, and its numbers never become prices.

Contents

What can a CI performance gate resolve?

The arithmetic below is for a rig like ours (Modelled, from the spreads measured in the sections that follow). Your rig has its own spreads, and an A/A run is how you find them.

  • One A/B run per commit. With a per-round spread of about 1%, the 95% range of a single paired difference is about ±2%. One run cannot tell a 2% change from 0% or from 4%.
  • 12 paired rounds. The standard error of the mean difference falls to about 0.29%. Add each session’s own offset of about 0.34% (one standard deviation) and the 95% half-width is about 0.9%. A 2% change is clear; a 1% change is borderline.
  • In-process pairs. Far tighter, but only for changes that can be switched at run time, and only after in-process numbers have been checked against restart-paired runs for that kind of change (the fast loop post).

So the price of resolving 2% on our rig is about 12 paired rounds, roughly 25 minutes of machine time per comparison with its A/A arm at the pace of our restart-paired runs. More rounds help less than you would hope: the between-session term does not shrink with repetition, so even with unlimited rounds one session’s 95% half-width stays near 0.7%. Our own rule is stricter than that arithmetic: under about 1% from one session is never a finding.

Where does benchmark noise come from?

Because the thing you change is small and everything around it moves. A proxied 4 KB request on loopback costs Envoy about half a million cycles on our server, split between its own code and the kernel. A patch or a setting often changes a few thousand to a few tens of thousands of them. Meanwhile the CPU clock, the caches, the layout of the binary in memory, the order in which connections land on worker threads and the load generator itself all vary from run to run.

Some of that variation is easy to miss because it looks like a result. Three examples from our own work, all caught before publication (the full list):

  • The load generator chose the workers. Nighthawk’s default HTTP/1 connection reuse kept reusing the most recent connections, so 2 to 4 of Envoy’s 4 workers carried the load, a different set in every run. Cycles per request followed the busiest worker’s share. Spreading the requests over every connection cut the spread of paired differences from 6.9% to 1.3% on one traffic shape.
  • The wrong binary. A later build repointed a build-output symlink, so three early verdicts rested on builds without optimization. Their gains of 37% to 89% were void. Every binary is now copied out, checked and hashed.
  • A bias that was chance. Same-binary runs seemed to show a small offset, at a z of about 2.7. It came from pooling statistics that should not be pooled. A run with the labels swapped settled it.

Each of these left a rule. Most of the rules below exist because something like this happened once.

Where the noise comes from: the spread of one paired difference, by what differs between its two halves Dot chart on a log scale of standard deviations in log points. Two 20-second windows in one Envoy process: 0.043. Two 10-second windows in one process: 0.080. The same comparison in another short process: 0.094. Two separate processes, one round: 0.84 to 1.11, across two calibrations. Two sessions on different days: 0.48, which is √2 times the 0.34 offset each session carries, a separate term on top of the per-round interval. A dashed line at 1 marks our reporting line: under about 1%, no finding from one session. 0.01 0.03 0.1 0.3 1 2 standard deviation, log points (about percent), log scale our reporting line, about 1%: under it, no finding from one session Two windows in one Envoy process, 20 s each first calibration, A/A pairs Two windows in one Envoy process, 20 s each: 0.043 log points (one standard deviation) 0.043 Two windows in one process, 10 s each second calibration, inside one instance Two windows in one process, 10 s each: 0.08 log points (one standard deviation) 0.080 The same comparison in another short process second calibration, between instances The same comparison in another short process: 0.094 log points (one standard deviation) 0.094 Two separate processes, one round restart-paired, one traffic shape, both calibrations Two separate processes, one round: 0.84 to 1.11 log points per round 0.84 to 1.11 Two sessions on different days √2 × a 0.34 offset per session; a separate term Two sessions on different days: 0.48 log points (one standard deviation), a separate term 0.48 Where the noise comes from: the spread of one paired difference, by what differs between its two halves Dot chart on a log scale of standard deviations in log points. Two 20-second windows in one Envoy process: 0.043. Two 10-second windows in one process: 0.080. The same comparison in another short process: 0.094. Two separate processes, one round: 0.84 to 1.11, across two calibrations. Two sessions on different days: 0.48, which is √2 times the 0.34 offset each session carries, a separate term on top of the per-round interval. A dashed line at 1 marks our reporting line: under about 1%, no finding from one session. One standard deviation, log points (log scale) our reporting line, about 1% Two windows in one Envoy process, 20 s each first calibration, A/A pairs Two windows in one Envoy process, 20 s each: 0.043 0.043 Two windows in one process, 10 s each second calibration, inside one instance Two windows in one process, 10 s each: 0.08 0.080 The same comparison in another short process second calibration, between instances The same comparison in another short process: 0.094 0.094 Two separate processes, one round restart-paired, one traffic shape, both calibrations Two separate processes, one round: 0.84 to 1.11 0.84 to 1.11 Two sessions on different days √2 × a 0.34 offset per session; a separate term Two sessions on different days: 0.48 0.48 0.01 0.03 0.1 0.3 1 2 Under the reporting line: no finding from one session.
The same Envoy, the same traffic: the spread of a paired difference depends on what changes between the two halves. Values are standard deviations in log points (about percent). The hollow dot is a different kind of term: the difference between two sessions, each of which carries its own offset of about 0.34, so no repetition inside a session removes it. On a 4 MiB bulk shape the per-round spread was about 0.37.

What does an A/A run tell you?

An A/A test (an A/A run) compares a binary and configuration with a second copy of themselves, in the same session, with the same pairing and the same analysis as the real comparison. Any difference it shows is the rig, not the change.

We use it three ways:

  • As a floor. On our test server the A/A floor was about 1.2% on HTTP/1 proxied responses in one session (0.7% to 1.7% in another, by shape and load) and about 1.9% on HTTP/2 (the method). An effect inside its session’s floor is not reported as a finding, whatever its own interval says.
  • As a bias check. Pooled over the A/A runs our method was set on, a systematic bias larger than about 0.2% is excluded. When a later session’s A/A disagrees, the rows that depend on it lose their verdict. That has happened: on one header-heavy shape the second copy read lower than the first in all seven blocks of two series, and we have not found why, so we claim no effect under about 1% on that shape.
  • As a gate on every comparison. A session whose same-build check fails gives No verdict for that cell, even if the change itself looks large.

Two lines, and the stricter one applies. The A/A floor is per session and per traffic shape: 0.7% to 1.7% on HTTP/1 and 1.9% on HTTP/2 in the sessions above. Separately, an effect under about 1% from one session is never a finding on any shape, because of the between-session term below. Usually the floor is the binding line; where a session’s floor was lower, the 1% line was. The 1% line is the limit that no session, however clean its A/A, gets under. An effect between 1% and 2% needs a second session, or an interval that still excludes zero once the between-session term is added.

The A/A does not cover the difference between sessions. Each session’s result carries its own offset of about 0.34% (one standard deviation) on top of its own interval, so two sessions of the same comparison differ by about 0.48% (√2 × 0.34), and no amount of repetition inside one session removes that term. We estimated it from 11 same-binary A/A comparisons in five separate A/A runs, on HTTP/1, HTTP/2 and TLS shapes, as the spread among those comparisons beyond what each one’s own interval explains (a random-effects standard deviation). The known case that strains it is ours: the restart-paired run in the fast loop post read −1.86% for a patch whose published row, from an earlier session, read −2.88%, a gap of about twice the 0.48% we expect between two sessions.

Inside one process or between processes?

The fastest way to compare two settings is to switch between them inside one running process. Envoy makes this easy: many patches sit behind a runtime guard that the admin interface can flip in well under a second. Nothing restarts, the caches stay warm, and only the switch changes.

The pairs are tight. In our first calibration, pairs of 20-second windows inside one Envoy process had a spread of 0.043 log points, about 25 times smaller than the per-round spread between separate processes in the same session (1.105). (A log point is 100 times the natural log of a ratio; at these sizes it reads as a percentage.)

That precision belongs to one process. When we flipped a known patch’s guard in two separate long-lived processes, its effect differed between them by 0.16 log points, about five times the uncertainty inside either one. An interval built from pairs inside one process is honest about that process and too confident about the software. Taken across the two processes (n = 2), the interval was [−2.84, −0.83], which is wide, and with two processes it can be no better than a rough bound.

A measurement inside one process may also be a different quantity. It measures what the switch does once everything else is warm and settled. A paired run between processes measures what running with the setting costs against running without it, start-up and binary layout included. Nothing says the two must be equal, so we checked. Post 2 has the result: across 12 short processes, that patch’s in-process effect matched a restart-paired run of the same comparison in the same session.

Our rules from this:

  • An in-process number carries two labels: “in-process effect” and Exploratory.
  • Its interval is taken across several separate processes, never across pairs inside one.
  • It is never scaled into a between-process number. We fit no correction factor.
  • Only a run between processes gives a published number.

Why fix the plan before the data?

Because a benchmark has many forks: which traffic shape, which rate, how many rounds, which rounds to drop, which comparison to report first. Choose any of them after seeing the data and you can find almost any effect you were hoping for. Clinical trials solve the same problem the same way: they register the plan first.

Before any measurement, our plan names:

  • the rows: each comparison, with its arms (the configurations being compared);
  • the design: rounds, balanced order (A-B-B-A for two arms, rotated for more), window length and rate;
  • the A/A floor and the validity gates a run must pass;
  • the kill lines: what result would stop the idea, and what each outcome would mean;
  • what is Exploratory: anything outside the named comparisons.

The plan is reviewed by AI agents through multiple independent lenses using top-tier models, and revised until every review signs off; the author then approves the plan, so no agent review clears it on its own. Then the session runs, the result is written up row by row, and that write-up is reviewed the same way.

Pre-registration costs something, and it shows in our results:

  • A threshold we could not confirm. One of our own patches had a threshold, set before the run, that the patched build should cost no more than 4% over no tracer. The point estimate came in 0.38 points under it, with an interval that crossed it. The row says Not resolved, and we did not re-run it to get a cleaner answer (the row).
  • A gate that failed. The first calibration of our fast loop had a gate fixed before the run. The loop’s estimate of a known effect missed it, so the gate read no-go, and that is how it stands in the record. We changed the design and wrote a new gate for a new session, rather than reinterpreting the old one (post 2).
  • A bet that could have lost. Before the second calibration, the plan put the odds of passing the new gate at about 2 to 1, and said what each outcome would allow. It passed for the per-request control (post 2).

When something has to change after the data, we say so next to the number. Post 2 has one example: a validity reference that the run never froze, recovered after the data under conditions written down before any restart figure was computed, with one ruling on a condition’s scope made after that condition’s output, and disclosed wherever that reading is used.

What does each label mean?

Every number we publish carries one basis label. They are the same on every Envoy post:

Label Meaning
Measured From paired or interleaved runs named in the plan, with the interval or range given.
No verdict Measured, but the same-build check in that cell missed our own rule.
Not resolved The change was inside the noise of those runs. That is not the same as no effect.
Exploratory Chosen after seeing the data, or outside the comparisons named before the run.
Modelled Arithmetic on measured inputs.
From a number to its label Decision tree. Start with a number. Was it named in the plan before any data? If no, it is Exploratory. If yes: is it arithmetic on measured inputs rather than measured itself? If yes, it is Modelled. If no: did the run pass every validity gate, and did its same-build A/A check pass? If the A/A check failed, the cell is No verdict; if the gates failed, the run is not counted, which is not a label. If both passed: does the effect clear the A/A floor and the between-session term? If no, it is Not resolved, which is not the same as no effect. If yes, it is Measured, with its interval and conditions. A number Named in the plan before any data? Exploratory no yes Arithmetic on measured inputs, not measured itself? Modelled yes no Did the run pass every validity gate, and did its same-build A/A pass? No verdict A/A missed A/A failed not counted not a label: the run is void gates failed both pass Does the effect clear the A/A floor and the between-session term? Not resolved not the same as no effect no yes Measured with its interval and conditions the only label that goes into a price list From a number to its label Decision tree. Start with a number. Was it named in the plan before any data? If no, it is Exploratory. If yes: is it arithmetic on measured inputs rather than measured itself? If yes, it is Modelled. If no: did the run pass every validity gate, and did its same-build A/A check pass? If the A/A check failed, the cell is No verdict; if the gates failed, the run is not counted, which is not a label. If both passed: does the effect clear the A/A floor and the between-session term? If no, it is Not resolved, which is not the same as no effect. If yes, it is Measured, with its interval and conditions. A number Named in the plan before any data? no Exploratory yes Arithmetic on measured inputs, not measured itself? yes Modelled no Did the run pass every validity gate, and did its same-build A/A pass? A/A failed No verdict A/A missed gates failed not counted not a label both pass Does the effect clear the A/A floor and the between-session term? no Not resolved not the same as no effect yes Measured with its interval and conditions The only label that goes into a price list.
Every number we publish carries one of five labels. Only Measured numbers go into a price list.

Two rules make the labels useful. A label never upgrades: an Exploratory number stays Exploratory even if a later run agrees with it, and the later run gets its own label. And Not resolved is a real outcome, published as such. A table with only wins in it has been filtered somewhere.

Why a price list?

A benchmark score answers “which is faster?” for one workload. People who run proxies ask a different question: what does this setting, this filter or this release cost per request, and under which conditions?

So our main output is a price list: one row per setting, feature, patch or release, each measured against the same proxy without the change, in CPU cycles per request, with its interval, its label and its conditions (traffic shape, rate, protocol, worker count, machine). Two examples from it: external authorization adds about 55% CPU per request with an HTTP service and 81% with gRPC (lower bounds), and the OpenTelemetry tracer at 0% sampling adds 6.7%.

A price list has three properties a score does not:

  • It gives a first-order budget. A team can add up the rows that match its configuration and get a rough first estimate of where its CPU goes before it profiles anything. Each row is measured alone against a baseline; how features interact when combined is not measured, apart from the one stack of seven features the list prices together.
  • It shows its own limits. A row measured at one rate on one machine says so, and a reader can see whether it applies.
  • It can be checked. The harness and the raw data behind every row are public (github.com/We-Amp/envoy-price-list), so a reader can rerun a row instead of trusting it.

Where does a fast loop fit?

The method above is slow on purpose. One idea goes through a plan, a review, a session on the test machine, a write-up and a second review. Many ideas end below our reporting line, and the cycle costs the same whether they do or not.

So we built a screening loop in front of it. An agent drives an extended Nighthawk and Envoy on the test machine through one SSH session, flips one setting at a time across 12 short Envoy processes, and gets a reply in cycles per request in about half an hour per candidate. Its numbers are stamped Exploratory and never become a published row or a price. It decides only what goes into the next pre-registered session, and that session decides.

Two tiers: the fast loop steers, a pre-registered paired session decides Top panel, tier 1, the loop: choose a step, run paired windows in 12 short Envoy instances with 10-second windows and an A/A pair in each, read the reply in cycles per request with its interval and gates, then keep or drop the idea and choose the next step. Every number in this tier is stamped Exploratory. The loop was checked against two patches, per request and per connection, each beside a same-session restart-paired run. A dashed line separates the tiers: loop numbers never become a published row or a price. Only a candidate record crosses it: the shape, the arms, the effect seen and the number of instances. Bottom panel, tier 2: a plan fixed before any data, with rows, kill lines and an A/A floor; an agent review through multiple independent lenses using top-tier models, to sign-off; a paired session in balanced order with gates that fail closed; a reviewed result with an interval and a basis. Only tier 2 rows are published. Tier 1: the loop steers every number stamped Exploratory Choose a step shape, arms, one runtime guard Run paired windows 12 short instances, 10 s windows, an A/A pair in each Read the reply cycles per request, interval, gates Keep or drop a dropped idea costs nothing more next step, chosen from the last reply Checked against two patches, per request and per connection, each beside a same-session restart-paired run. Loop numbers stop here: they never become a published row or a price only a candidate record crosses: shape, arms, effect seen, instances Tier 2: a pre-registered session decides Measured, Not resolved or No verdict Plan before data rows, kill lines, an A/A floor Agent review independent lenses, of the plan, to sign-off Paired session balanced order, A/A, gates that fail closed Reviewed result a row with its interval and its basis Only these rows are published. The loop's own estimate is not carried into the session's analysis. Two tiers: the fast loop steers, a pre-registered paired session decides Top panel, tier 1, the loop: choose a step, run paired windows in 12 short Envoy instances with 10-second windows and an A/A pair in each, read the reply in cycles per request with its interval and gates, then keep or drop the idea and choose the next step. Every number in this tier is stamped Exploratory. The loop was checked against two patches, per request and per connection, each beside a same-session restart-paired run. A dashed line separates the tiers: loop numbers never become a published row or a price. Only a candidate record crosses it: the shape, the arms, the effect seen and the number of instances. Bottom panel, tier 2: a plan fixed before any data, with rows, kill lines and an A/A floor; an agent review through multiple independent lenses using top-tier models, to sign-off; a paired session in balanced order with gates that fail closed; a reviewed result with an interval and a basis. Only tier 2 rows are published. Tier 1: the loop steers every number stamped Exploratory Choose a step shape, arms, one runtime guard Run paired windows 12 short instances, 10 s windows, an A/A pair in each Read the reply cycles per request, interval, gates Keep or drop a dropped idea costs nothing more next step, chosen from the last reply Checked against two patches, per request and per connection, each beside a same-session restart-paired run. Loop numbers stop here: they never become a published row or a price only a candidate record crosses: shape, arms, effect seen, instances Tier 2: a pre-registered session decides Measured, Not resolved or No verdict Plan before data rows, kill lines, an A/A floor Agent review independent lenses, of the plan, to sign-off Paired session balanced order, A/A, gates that fail closed Reviewed result a row with its interval and its basis Only these rows are published. The loop's own estimate is not carried into the session's analysis.
The two-tier rule. The loop's numbers stay Exploratory and only choose what to measure next; a candidate becomes a row in a plan fixed before data, and only that paired session gives a verdict.

A fast loop is only useful if it tracks a between-process run of the same change, so before using it we checked it against two patches of ours with runtime guards, one per request and one per connection, each against a restart-paired run in the same session. Envoy benchmarking with an extended Nighthawk has the design, the numbers and what the loop cannot do. The rule that the loop’s agent may steer but never decide is the one we use for agents elsewhere: checks, not prose.

How does this relate to other methods?

None of the parts is new on its own. Two lines of prior work are close to ours.

  • Layout randomization. Mytkowicz and colleagues showed in 2009 that changes as small as the size of the environment or the link order can bias a measurement by more than the effect under study (“Producing wrong data without doing anything obviously wrong!”). Stabilizer (Curtsinger and Berger, 2013) answers that by re-randomizing code, stack and heap layout during the run, so layout becomes noise that averages out. We do not randomize layout. We restart the process every round and pair rounds in balanced order, so the restart-to-restart variation, layout included, is inside the per-round spread we report. Randomization would shrink that spread; we have not tried it.
  • Change-point detection. Many performance-testing setups run a benchmark once per commit and look for shifts in the history afterwards, for example with E-divisive means (Matteson and James, 2014). That finds regressions cheaply across many commits, after the fact. A paired, A/A-gated comparison answers a different question: does this one change move CPU per request, and by how much, with an interval. The two fit together: change-point detection to find the commit, a paired comparison to price it.

What we add is mostly discipline around these ideas: a plan fixed before the data, a label on every number, a published A/A floor per session, and a fast loop that is calibrated against the slow method before it is used.

Where does this apply?

Every number in this series comes from one dedicated two-socket server from 2016, over loopback, with Envoy running 4 workers on CPUs it does not share. That is the best case for noise: no network card, no neighbours, a fixed frequency setting with the default idle states, checked on every run. A CI runner on shared or virtualized hardware is usually noisier, so its A/A floor is likely higher than ours, and its gate can resolve less for the same number of runs. So run the A/A on the CI hardware itself; our floors will not transfer. If you want that number for your own runners, we can measure it with you.

We have run the method on Envoy only. The ideas (an A/A floor, a plan before the data, labels, a calibrated screen) should carry over to other proxies and services measured in CPU per request; the spreads, floors and run counts will not, and have to be measured again.

What will this series cover?

Two parts are published:

  1. This post: the ideas.
  2. Envoy benchmarking with an extended Nighthawk: the fast loop, our Nighthawk changes, and the calibration against restart-paired runs.

Planned, in no fixed order and without dates:

  • Five ways a load generator skewed our numbers, and the client changes behind each fix.
  • Measuring a moment: how to price a transient event, such as a configuration push or a reconnect wave, against a null event.
  • Does a saving hold at every load? A rate ladder for one patch.
  • Reproducing a number from a fresh clone, by someone other than the author.
  • Latency you can trust under load, with requests timed from when they were due.

The Envoy findings themselves stay in Envoy performance, measured; this series is Proxy benchmarking.

Corrections go to the harness’s issue tracker.

← All writing