Skip to main content

Envoy performance · part 10 of 12

What Envoy's stats cost in CPU: flushes, sinks and counters

By Otto van der Schaaf, We-Amp ·

Envoy’s stats (its metrics) cost CPU in two places: the periodic flush on the main thread, and the updates every request makes on the workers. We measured both on the official v1.40.2 binary. With no sink, a flush of 1,180,396 stats took 261.2 to 267.0 ms of main-thread time at flush intervals of 1, 5 and 20 s; a plain statsd sink added 2,130 ms. Under load at 118,396 stats and 5,200 requests per second, statsd added about 20% to total CPU cycles per request (+19.69% [+18.70, +20.69]) and the OpenTelemetry sink 1.66%. Turning the store’s stats off saved 1.98% [0.99, 2.95] of worker cycles per request at 36% busy with 28 workers, a lower bound on what stat updates cost because per-host stats stayed on.

This covers one release binary, one bare-metal server with two Intel Xeon E5-2673 v4 sockets, loopback networking, one upstream host, and workers 26% and 36% busy in the stats-off runs on that server (42% to 47% with the extra counters of the shared-counter run). One end-to-end comparison ran on the Arm cloud VM, at about 21% busy. The microbenchmarks also ran on two cloud VMs. A flush did not measurably delay requests while the main thread had a core of its own. Whether shared counters cost more as workers are added was not resolved; we say how far the intervals reach.

The flush-path part of this study starts from a design document by Joshua Marantz (Google), Improving Stats Sink Efficiency, and its issue, and tests one option named there. The patches in this post are on our fork. Any error in them is ours. This post is part of our account of the whole Envoy CPU effort.

Key findings

  • A statsd sink is the large cost. Under load at 118,396 stats and 5,200 requests per second, with a 5 s flush interval on loopback, a plain statsd sink added about 20% to total CPU cycles per request (19.69% in the table), buffered dog_statsd 17.78% and the OpenTelemetry sink 1.66%. The OTLP figure is its flush spread over the requests, so it scales with the interval, the rate and the stat count.
  • Most of the statsd cost is on the workers. v1.40.2 sends every histogram sample as its own UDP datagram as the request completes, about 3.0 per request. The worker figure includes the loopback receive path, whose share was not separated. dog_statsd’s buffer groups only the flush’s lines, so it barely lowered the cost.
  • A flush is long, but with the main thread on a core of its own it did not measurably delay requests (p99 over a whole flush, 4 rounds; in a flush’s first 70 ms the interval reaches +1.1 ms). With no sink, a flush of 1,180,396 stats took 261.2 to 267.0 ms of main-thread time at flush intervals of 1, 5 and 20 s; a plain statsd sink added 2,130 ms. With the main thread hard-pinned onto a worker’s core, a worst case, that worker’s p99 rose by 3,547 µs during a flush.
  • Turning the store’s stats off saved 1.98% [0.99, 2.95] of worker cycles per request at 36% busy with 28 workers, a lower bound on what stat updates cost because per-host stats stayed on. Whether shared counters cost more as workers are added was not resolved.

What to do: if you run a statsd sink at a high request rate, look first at its per-request histogram datagrams; an opt-in patch on our fork that batches them cut CPU per request by about 8% in a later session. At stat counts where a flush runs for hundreds of milliseconds, leave a core free for the main thread.

Contents

The results at a glance

Every row is on the official v1.40.2 binary and the bare-metal server unless it says microbenchmark. Intervals are 95%.

Question Result Conditions Basis
CPU per request with a statsd sink +19.69% [+18.70, +20.69] 118,396 stats, 5,200 req/s, 4 workers, 5 s flush interval, loopback Measured
Same, buffered dog_statsd +17.78% [+16.63, +18.93] same Measured
Same, OTLP +1.66% [+0.69, +2.65] same; the flush amortized over the requests Measured; small, the near end of the interval is under 1%
Main-thread time per flush, no sink 11.04 ms [10.89, 11.19] at 118,396 stats; 266.5 ms [261.6, 271.3] at 1,180,396 no client load, 4 workers, 1 s interval; one session, and the intervals are within that session Measured, descriptive
Added per flush by statsd, buffered dog_statsd, OTLP +2,130 ms [+2,109, +2,151]; +655 ms [+646, +664]; +1,013.0 ms [+997.0, +1,029.0] 1,180,396 stats, no client load; within-session intervals (the same-build repeat’s half-width was 2.64%, and 3.77% in the OTLP session) Measured
Request p99 inside a flush minus outside, main thread on its own core −8 µs [−27, +11] with no sink 1,180,407 stats, 5,200 req/s, 4 rounds Measured; not a finding, inside the 120 µs floor
Same, main thread pinned onto a worker’s core +3,547 µs [+3,358, +3,736] on that worker a hard pin, the worst case without a CPU quota Measured
Longest wait for /ready during a flush 0.37 s with no sink, 2.50 s with statsd 1,180,407 stats, main thread on its own core Measured, descriptive
Worker cycles per request with the store’s stats rejected −1.98% [−2.95, −0.99]; about 3.9% of user instructions 28 workers, 36% busy; per-host stats stay on Measured; a lower bound
Growth of that cost with workers, sockets or load none resolved; the planned test has no verdict 26% and 36% busy, one two-socket server No verdict; Not resolved where both cells passed
Shared against per-connection counters none resolved, and no cell has a verdict; the intervals reach +1.3% to +2.9% 64 to 128 extra increments per request, 42% to 47% busy, 5 or 6 rounds; the same-arm repeat read −0.69% and the arm order was a fixed rotation No verdict
One counter updated by every thread as fast as it can 44.4x [43.4, 45.4] the uncontended cost at 19 threads microbenchmark of a model counter, a worst case; the end-to-end runs did not reach this regime Measured
Relaxed memory ordering on counter increments under 1% on the x86 server’s model counter; not resolved on the x86 VM (within 2% on the model, within 10% on the real counter) or on Arm (within 5%) microbenchmark; end to end at most 0.04% Measured (server); Not resolved (VMs); end to end Modelled

The Basis column uses five words, in the same sense throughout.

  • Measured. The comparison and its rule were stated before the run, the run passed its validity gates, and the number was recomputed from the raw legs by a second analysis. A measured number that describes a level and tests no comparison says “descriptive”. For the microbenchmarks the hypotheses were stated before the runs and the timing method was rebuilt after two void rounds, before the rounds used here.
  • No verdict. Measured the same way, but the same-build repeat in that cell missed its gate, so under our own rule the cell supports no conclusion. The number is printed anyway.
  • Not resolved. The interval includes zero. Where a bound is printed, it is the far end of the 95% interval.
  • Exploratory. Chosen after seeing the data, or outside the comparisons stated before the run.
  • Modelled. Arithmetic on measured inputs, with the assumptions stated.

What this does not cover

These limits apply to every number below.

Loopback and local receivers. Client, origin, sink receivers and the OTLP collector run on the same machine. The statsd receivers discard what they read and the collector uses a nop exporter. Kernel cycles charged to the proxy include the loopback receive path; its share of the statsd worker cost is not quantified. net.core.rmem_max was raised, and every sink leg was granted a 512 MiB receive buffer.

A minimal filter chain. Plain HTTP/1.1 through the router filter to one cluster, keep-alive connections, no TLS. That is 17 store-stat operations per request; filters, TLS, HTTP/2 and per-route stats add more, none of it priced here.

One way of generating stats. Stat count was varied by adding static clusters with one endpoint each: 1,000 clusters give 118,396 stats and 10,000 give 1,180,396, about 360,000 of them in use. Nothing here separates stat count from cluster count.

Light to moderate load. The stats-off runs sit at 26% and 36% worker busy, the shared-counter run at 42% to 47%; the plan aimed for 60% to 70% and missed it. Every figure here is from an unsaturated proxy.

One machine, one upstream host. The server has 2 x 20 cores. It could not push a single cache line into the regime where updates queue behind each other, so wider machines remain untested.

Store stats only. Per-host stats stay on in every “stats off” figure, so those figures are lower bounds.

Today’s flush cost. v1.40.2 already contains two merged ref-count fast paths for the flush (#45821 and #46001, both in v1.39.0 and later). The flush figures are the cost after those.

Not measured. Memory per stat; the cost of a Prometheus scrape of the admin port; tag extraction, stat-name cardinality and histogram bucket settings; xDS activity behind a flush (only /ready was probed); and any request-path run of the patched builds, whose stat-update changes exist as microbenchmarks only. Every end-to-end figure in this post is from the official release binary; PGO and ThinLTO builds are priced separately.

How we measured

The method is the price list’s: paired rounds, a fixed open-loop rate, cycles counted on the proxy alone and a validity gate that fails closed. See how every number in the price list is measured and the rules the earlier posts were measured under.

Where the stats cost CPU

A stat costs CPU in two places, on two kinds of thread. The figure shows the path and where this post’s main figures land.

Where Envoy's stats cost CPU: the worker threads, the main thread's flush and the sink Three boxes from left to right. Worker threads: every request makes 14 counter increments and 3 histogram samples in the stats store; counters and gauges are atomics shared by all workers, histograms are kept per worker, and per-host stats come on top. Main thread: at every flush interval it posts a merge to every worker, each worker swaps its histogram buffers, and the main thread merges the histograms, reads the shared counters and gauges and hands a snapshot to each sink; an arrow from the main thread to the workers marks the merge. Stats sinks: statsd sends one datagram per line, dog_statsd packs lines into datagrams, OTLP exports over gRPC in requests of 10,000 points. An extra arrow goes from the workers straight to the sink: with statsd and dog_statsd only, every histogram sample is sent from the worker that recorded it as its own datagram, about 3.0 per request. Below, where the CPU lands. On the workers, per request: statsd added 16.3% of worker cycles (an exploratory figure), and rejecting every store stat saved 1.98% of worker cycles, a lower bound. On the main thread, per flush: 261 to 267 ms with no sink at 1,180,396 stats, plus 2,130 ms with statsd or 1,013 ms with OTLP, and admin requests wait until the flush ends. Worker threads every request: 14 counter increments, 3 histogram samples (store stats) counters, gauges: shared atomics; histograms: one set per worker per-host stats on top Main thread at every flush interval: posts a merge to every worker, which swaps its histogram buffers; merges them, reads the shared counters and gauges, hands a snapshot to each sink Stats sinks statsd: one datagram per line dog_statsd: lines packed into datagrams OTLP: gRPC, 10,000 points per request merge snapshot statsd and dog_statsd only: every histogram sample is sent from the worker that recorded it as its own datagram, about 3.0 per request WHERE THE CPU LANDS On the workers, per request statsd: +16.3% of worker cycles (exploratory; 5,200 req/s, 118,396 stats) every store stat rejected: −1.98%, a lower bound (28 workers) On the main thread, per flush no sink: 261 to 267 ms at 1,180,396 stats statsd adds 2,130 ms; OTLP 1,013 ms admin requests wait for the flush Where Envoy's stats cost CPU: the worker threads, the main thread's flush and the sink Three boxes from top to bottom. Worker threads: every request makes 14 counter increments and 3 histogram samples in the stats store; counters and gauges are atomics shared by all workers, histograms are kept per worker, and per-host stats come on top. Main thread: at every flush interval it posts a merge to every worker, each worker swaps its histogram buffers, and the main thread merges the histograms, reads the shared counters and gauges and hands a snapshot to each sink; an arrow from the main thread to the workers marks the merge. Stats sinks: statsd sends one datagram per line, dog_statsd packs lines into datagrams, OTLP exports over gRPC in requests of 10,000 points. An extra arrow runs down the right side from the workers straight to the sink: with statsd and dog_statsd only, every histogram sample is sent from the worker that recorded it as its own datagram, about 3.0 per request. Below, where the CPU lands. On the workers, per request: statsd added 16.3% of worker cycles (an exploratory figure), and rejecting every store stat saved 1.98% of worker cycles, a lower bound. On the main thread, per flush: 261 to 267 ms with no sink at 1,180,396 stats, plus 2,130 ms with statsd or 1,013 ms with OTLP, and admin requests wait until the flush ends. Worker threads every request: 14 counter increments, 3 histogram samples (store stats) counters, gauges: shared atomics; histograms: one set per worker per-host stats on top merge Main thread at every flush interval: posts a merge to every worker, which swaps its histogram buffers; merges them, reads the shared counters and gauges, hands a snapshot to each sink snapshot Stats sinks statsd: one datagram per line dog_statsd: lines packed into datagrams OTLP: gRPC, 10,000 points per request statsd and dog_statsd only: every histogram sample is sent from the worker that recorded it as its own datagram, about 3.0 per request (the side arrow) WHERE THE CPU LANDS On the workers, per request statsd: +16.3% of worker cycles (exploratory; 5,200 req/s, 118,396 stats) every store stat rejected: −1.98%, a lower bound (28 workers) On the main thread, per flush no sink: 261 to 267 ms, 1,180,396 stats statsd adds 2,130 ms; OTLP 1,013 ms admin requests wait for the flush
Where the stats cost CPU in Envoy v1.40.2, with the figures this post measured. The per-request counts are for the minimal configuration measured here (plain HTTP/1.1 through the router filter to one cluster). Per request, the workers update the store's counters and record histogram samples; at each flush interval the main thread merges the histograms (each worker first swaps its buffers), reads the shared counters and gauges and hands a snapshot to the sink. A statsd or dog_statsd sink also sends every histogram sample from the worker as its own datagram, which is why most of their cost sits on the workers. Worker figures: 4 workers at 5,200 requests per second with 118,396 stats (the statsd row), and 28 workers at 36% busy (the rejected-stats row, a lower bound because per-host stats stay on). Main-thread figures: no client load, 1,180,396 stats. One two-socket Xeon E5-2673 v4 server, loopback.

Machines

The end-to-end runs used a bare-metal server with two Intel Xeon E5-2673 v4 sockets (2016, 20 cores and 40 threads each), clock fixed at 2.3 GHz, turbo off; 32 KiB L1d and 256 KiB L2 per core, 50 MiB L3 per socket. The proxy’s workers were pinned one per core with their sibling threads idle. The exception is the Arm stats-off run, on the Arm VM below.

The microbenchmarks also ran on two shared-tenancy cloud spot VMs with the hardware counters exposed:

  • an x86 cloud VM on Intel Xeon Platinum 8581C (Emerald Rapids, 2.3 GHz): 16 virtual CPUs, which are 8 cores with two threads each; we used one thread per core and left the siblings idle; 48 KiB L1d and 2 MiB L2 per core, 260 MiB L3 as the guest reports it;
  • an Arm cloud VM on Neoverse V2 cores: 16 virtual CPUs, one per core, no SMT; 64 KiB L1d and 2 MiB L2 per core, 80 MiB L3 as the guest reports it; clock about 3.0 GHz, not fixed.

Comparisons are ratios within one machine. Load in the sink and latency runs came from Nighthawk in open-loop mode. (The author of this post is an emeritus maintainer of Nighthawk.)

Rules stated before the runs

  • A same-build repeat decides whether a cell gets a verdict. Each run carries a second copy of its reference arm in the same rounds (an A/A pair). For cycles per request, the A/A interval must have a half-width of at most 1% and show no difference after correction (uncorrected in the shared-counter run); otherwise the cell has no verdict, whatever its own interval says. A contrast between two cells needs both to pass. For main-thread time per flush the target is 2% (3% in the OTLP re-run session). A flush cell that misses it keeps its row; its ratio is then widened by the repeat’s own half-width and must still clear the repeat’s far end.
  • Order. Within a round the arms run in a rotated order (A-B-B-A for two arms). In the shared-counter and latency runs that rotation was a cyclic shift: each arm takes each position about equally often, but always follows the same arm, so an effect of one leg on the next is not averaged out.
  • Intervals are widened by the spread between sessions, where that spread is known. The half-width is the larger of the plain t half-width and 1.96 x sqrt(SE² + 0.34²), in percent. 0.34% is one standard deviation of the same-build offset between sessions, estimated from 11 comparisons in 5 earlier sessions at 25% to 33% busy. The figure is rough and has not been checked on main-thread time per flush. The sink rows under load, the stats-off rows at 36% busy and the shared-counter rows carry it; everything else carries plain t intervals. With 5 or 6 rounds the plain t interval can be wider, and the wider one is printed.
  • Small numbers. Under 1%, or inside the far end of the same-build repeat’s interval, is not a finding. Between 1% and 2% counts only if the widened interval excludes zero.
  • Multiple comparisons. The comparisons to test were fixed per run before the data, and significance is corrected over that set (Holm). One exception: for the stats-off runs the plan named the worker-count and cross-socket contrasts and left the per-layout rows descriptive. At 36% busy we gave them a verdict under the rules above, with a correction over six rows chosen after the data. The 28-worker row passes with any of the sets we considered (corrected p 0.0006). Printed intervals are per comparison and are not adjusted.
  • Invalid legs repeat their whole round. Every arm of the round runs again, so pairs stay within one block. Invalid and superseded legs stay in the published data. One gate recurs below: other tasks may use at most 0.05 of a CPU on the proxy’s cores during the measurement window.

The runs

Run, as named below Workers Load Rounds Legs
Sink session, no client load 4 none; each cluster primed with one request 10 at 118,396 stats, 8 at 1,180,396 64 at 1,180,396 stats; 8 OTLP legs later ruled invalid
OTLP re-run at 1,180,396 stats 4 none 9 –
Sink session, under load 4 5,200 req/s; 30.7% to 36.2% busy by arm 10 50
Flush-latency run 4 5,200 req/s; about 31% busy (about 35% with statsd) 4 36 run, 33 valid
Stats-off run at 26% busy 1, 4, 14, 14 over two sockets, 28 1,000 req/s per worker 15 231 recorded, 225 current and valid, 2 invalid
Stats-off run at 36% busy 14, 14 over two sockets, 28 1,500 req/s per worker 15 (14 complete at 14 workers on one socket) 159 run, 149 valid, 10 invalid
Shared-counter run 14, 14 over two sockets, 28 1,500 req/s per worker; 42% to 47% busy 6 106 run, 8 invalid
Arm stats-off run 4, 12 1,000 req/s per worker; about 21% busy 20 120 of 120 valid on the release binary
Microbenchmarks 1, 4, 19 threads (server); 1, 4, 7 (x86 VM); 1, 4, 12 (Arm VM; 15 for the histogram benchmark) every thread updating as fast as it can 5, each the median of 5 repetitions a process with any rejected case is not counted

The sink and latency runs send 4 KB proxied HTTP/1 responses. The stats-off and shared-counter runs send a small request to one cluster with one upstream host, over HTTP/1.1, with 16 connections per worker.

What does a sink cost per request under load?

At 5,200 requests per second and 118,396 stats, with a 5 s flush interval (stats_flush_interval: 5s), a plain statsd sink added 19.69% to the proxy’s total cycles per request, buffered dog_statsd 17.78% and the OTLP sink 1.66%. The same-build repeat read −0.15% [−1.02, +0.73].

Proxy cycles per request by stats sink at 5,200 requests per second and 118,396 stats No sink: 518.9 thousand cycles per request. statsd: 621.1 thousand. Buffered dog_statsd: 611.1 thousand. OTLP: 527.5 thousand. Official v1.40.2, 4 workers, 5 second flush interval, loopback. No sink No sink: 518.9k cycles per request 518.9k statsd statsd: 621.1k cycles per request 621.1k Buffered dog_statsd Buffered dog_statsd: 611.1k cycles per request 611.1k OTLP OTLP: 527.5k cycles per request 527.5k
Proxy cycles per request by stats sink at 5,200 requests per second and 118,396 stats No sink: 518.9 thousand cycles per request. statsd: 621.1 thousand. Buffered dog_statsd: 611.1 thousand. OTLP: 527.5 thousand. Official v1.40.2, 4 workers, 5 second flush interval, loopback. No sink 518.9k No sink: 518.9k cycles per request statsd 621.1k statsd: 621.1k cycles per request Buffered dog_statsd 611.1k Buffered dog_statsd: 611.1k cycles per request OTLP 527.5k OTLP: 527.5k cycles per request
Mean total cycles of the proxy process per request, official Envoy v1.40.2, 4 workers, 5,200 requests per second, 118,396 stats, flush interval 5 s, 10 rounds. Bars start at zero. One stat count, one rate, one interval; loopback.
Arm Cycles per request (mean) Total, against no sink Workers only, against no sink Datagrams per request Main-thread run time per 5 s
No sink 518.9k reference reference none 24.4 ms
statsd 621.1k +19.69% [+18.70, +20.69] +16.3% [+15.6, +16.9] 4.21 228 ms
Buffered dog_statsd 611.1k +17.78% [+16.63, +18.93] +16.8% [+15.8, +17.7] 3.10 86 ms
OTLP 527.5k +1.66% [+0.69, +2.65] +0.03% [−0.77, +0.84] none 120 ms
No sink, second copy – −0.15% [−1.02, +0.73] – – –

Total cycles per request are user plus kernel cycles of the proxy process divided by the responses it served; 10 rounds. The total column is the tested comparison: Measured, with widened 95% intervals (the second-copy row is not a finding), corrected over the nine sink rows of the session; the OTLP row is small. The other columns are exploratory or descriptive.

Where the statsd cost sits

Most of it is on the workers: their own cycles per request rose 16.3% (an exploratory column, measured as a share of worker cycles). In v1.40.2 the statsd sinks send every histogram sample as its own datagram from the worker that recorded it (UdpStatsdSink::onHistogramComplete), as the request completes. Each request sent 4.21 datagrams, about 3.0 of them such samples. The figure includes the loopback receive path and is the price of one datagram per line on this setup. A patch of ours that batches those samples is priced in the price list and listed with the other candidates. Inside a stack of seven features, with a few hundred stats in place of 118,396, the same sink added +12.40% [+10.92, +13.91] against the stack without it (Exploratory; one session on 23 November, 5,200 req/s).

Why buffering lowers it so little

The buffer is max_bytes_per_datagram on DogStatsdSink, here 1,432 bytes; plain StatsdSink has no such field, so the buffered arm is a different sink. It cut datagrams per request from 4.21 to 3.10. The buffer applies to the flush only. Histogram samples bypass it, about 3.0 per request in both arms, so no change in the worker cost was resolved (+16.8% against +16.3%, an exploratory column). The two sinks were not compared directly. dog_statsd lines also carry tags: about 102 bytes against 78.

With OTLP the workers did not change. The 1.66% is the flush, an extra 96 ms of main thread per 5 s, spread over the requests of that interval: about 8.5k cycles per request at this rate. It scales with the interval, the rate and the stat count; CPU per request under load asks how a price moves with the rate. Tracing is a separate cost, priced in the price list’s tracing rows.

An earlier session measured the same statsd configuration against a proxy with flushing off and read +19.9% [+18.2, +21.6]. Expressed the same way, this session reads about +20.1%. The +19.69% here is from the session of 19 November (10 rounds). The price list’s batched statsd row measured the same comparison, the official binary with a plain statsd sink against no sink, under the same conditions in a session on 21 November (8 rounds): +19.4% [+18.5, +20.3]. The two intervals overlap; we quote each with its session and do not pool them.

Data: asset stats-2026-11-data-sink-types.tar.gz (unpacked: data/stats/sink-types/); outputs under docs/stats-tables/sink-types/ (release, tables)

What does a stats flush cost the main thread?

With no sink configured and no client load, a flush took 11.04 ms [10.89, 11.19] of main-thread run time at 118,396 stats and 266.5 ms [261.6, 271.3] at 1,180,396 stats, both at a 1 s interval. The flush runs on the main thread, so for that time the main thread does nothing else. With no sink the flush still merges the histograms and builds a snapshot, which takes and drops a reference on every stat and latches every counter.

The flush interval did not change the price of one flush by more than about 5%: at 1,180,396 stats it was 266.5 ms at 1 s, 261.2 ms [256.2, 266.2] at 5 s and 267.0 ms [261.6, 272.4] at 20 s. These are levels, so they are descriptive. An earlier session measured 12.73 ms [12.56, 12.91] at 118,396 stats with a slightly different definition of the flush. In that session’s terms this one reads about 11.8 ms, 7% lower (the 11.04 ms printed here is 13% lower); we have not shown the cause. The intervals here describe this session; between sessions the figure has moved by 7%.

In our runs, flush starts were one interval apart whatever the flush took, although the source re-arms the flush timer only after the flush returns. We report the spacing we measured. On that spacing, the share of a core the main thread spends flushing is the flush duration divided by the interval.

Data: asset stats-2026-11-data-sink-types.tar.gz (unpacked: data/stats/sink-types/); outputs under docs/stats-tables/sink-types/ (release, tables)

What does a stats sink add to a flush?

At 1,180,396 stats, plain statsd added 2,130 ms [+2,109, +2,151] of main-thread time to each flush, buffered dog_statsd 655 ms [+646, +664] and OTLP 1,013.0 ms [+997.0, +1,029.0], on a proxy with no client load.

Main-thread run time per stats flush at 1,180,396 stats, by sink No sink: 266.5 milliseconds. statsd: 261.2 with no sink plus 2,130 added by the sink. Buffered dog_statsd: 261.2 plus 655. OTLP: 266.6 plus 1,013.0. Official v1.40.2, 4 workers, no client load. No sink, same interval Added by the sink No sink No sink, 1 s interval: 266.5 ms 266.5 ms statsd No sink, 5 s interval: 261.2 ms Added by statsd: 2,130 ms +2,130 ms Buffered dog_statsd No sink, 5 s interval: 261.2 ms Added by buffered dog_statsd: 655 ms +655 ms OTLP No sink, 20 s interval, re-run session: 266.6 ms Added by OTLP: 1,013.0 ms +1,013.0 ms
Main-thread run time per stats flush at 1,180,396 stats, by sink No sink: 266.5 milliseconds. statsd: 261.2 with no sink plus 2,130 added by the sink. Buffered dog_statsd: 261.2 plus 655. OTLP: 266.6 plus 1,013.0. Official v1.40.2, 4 workers, no client load. No sink, same interval Added by the sink No sink 266.5 ms No sink, 1 s interval: 266.5 ms statsd +2,130 ms No sink, 5 s interval: 261.2 ms Added by statsd: 2,130 ms Buffered dog_statsd +655 ms No sink, 5 s interval: 261.2 ms Added by buffered dog_statsd: 655 ms OTLP +1,013.0 ms No sink, 20 s interval, re-run session: 266.6 ms Added by OTLP: 1,013.0 ms
Main-thread run time per stats flush at 1,180,396 stats, official Envoy v1.40.2, 4 workers, no client load, on a two-socket Xeon E5-2673 v4 server fixed at 2.3 GHz. The grey part is the no-sink flush at the same interval (266.5 ms at 1 s, 261.2 ms at 5 s, 266.6 ms at 20 s in the OTLP session); the coloured part is sink minus no sink, paired by round (8 rounds; OTLP from a separate session of 9 rounds). Sinks receive on loopback and discard.
Sink Stats Flush interval Added main-thread time per flush Per line or point
statsd 118,396 1 s +209.7 ms [+206.2, +213.1] 6.74 µs per line [6.63, 6.85]
statsd 1,180,396 5 s +2,130 ms [+2,109, +2,151] 6.87 µs per line [6.80, 6.93]
Buffered dog_statsd 118,396 1 s +61.1 ms [+60.6, +61.6] 1.96 µs per line; 26.4 µs per datagram
Buffered dog_statsd 1,180,396 5 s +655 ms [+646, +664] 2.11 µs per line; 28.6 µs per datagram
OTLP 118,396 1 s +92.4 ms [+91.7, +93.1] 2.56 µs per point [2.54, 2.58]
OTLP 1,180,396 20 s +1,013.0 ms [+997.0, +1,029.0] 2.81 µs per point [2.77, 2.86]

Sink minus no sink at the same interval, paired by round; 10 rounds at 118,396 stats, 8 at 1,180,396 with 4 flushes per leg, 9 for the OTLP row at 1,180,396 (a separate session, 3 flushes per leg). Every row is Measured. The intervals are plain 95% t intervals within one session. The same-build repeat missed its target in these cells (half-widths 2.28% at 118,396 stats and 2.64% at 1,180,396 with a 5 s interval; in the OTLP session 3.77% per flush against a 3.00% target), so each row was tested as a ratio to no sink, widened by that half-width; every row clears the repeat’s far end by a wide margin, and those ratio intervals are in the data directory. Corrected over the nine sink rows of the session.

Plain statsd makes one send call per line. A flush sent 31,112 lines at 118,396 stats and 310,152 at 1,180,396; unused stats are skipped, so the line count is well below the stat count. The kernel share at the smaller size was 72%, and the loopback receive path is part of it. At 1,180,396 stats the whole flush took 2,391 ms [2,374, 2,408]: at a 5 s interval, 48% of a core for the main thread (derived).

Buffered dog_statsd cut the price per line to 29% and 31% of plain statsd’s, and the kernel share fell from about 70% to about 20% (both exploratory and derived). A datagram carried 13.5 lines at the smaller size. The harness has no expected datagram count of its own for this arm, so its evidence rests on a pre-run check, and loss at 1,180,396 stats is bounded only to about 1%.

The OTLP sink exports one point per stat in use, in gRPC requests of 10,000 points, to a local collector that discards them. At 1,180,396 stats (360,146 points) the whole flush took about 1.28 s of main-thread time on an idle proxy, and 1.32 s wall time (median) with 5,200 requests per second running. A flush of that size does not fit a 1 s interval. The kernel share at the smaller size was 6%. The OTLP row at 1,180,396 stats is from a re-run with the collector’s receive limit raised; in the first session the collector rejected 13.9% of the points of every flush, and those 8 legs are in no table here.

A second session agrees with the statsd rows: 6.79 and 6.96 µs per line against 6.74 and 6.87 here, and 211.0 and 2,159 ms added against 209.7 and 2,130.

Data: asset stats-2026-11-data-sink-types.tar.gz (unpacked: data/stats/sink-types/); outputs under docs/stats-tables/sink-types/. For the earlier session: asset stats-2026-11-data-sink-flush-cost.tar.gz (unpacked: data/stats/sink-flush-cost/); table docs/stats-tables/sink-flush-cost/tables.md (release, tables, tables.md)

Does a stats flush delay requests?

Not measurably, when the main thread has a core of its own: p99 latency inside a flush was within 21 µs of p99 outside it with no sink, with statsd and with OTLP, against a floor of 120 µs stated before the run. That holds for p99 over a whole flush with 4 rounds; for the first 70 ms of a flush the interval reaches +1.1 ms. With the main thread pinned onto a worker’s core, that worker’s p99 rose by 3,547 µs during a flush. On the admin port, /ready waited for nearly the whole flush.

The run used 10,000 primed clusters (1,180,407 stats, 11 more than in the sink session, a difference we did not attribute), a 10 s flush interval, 5,200 requests per second on 4 workers, 60 s windows. Of those requests, 800 per second came from our own open-loop probe, 4 keep-alive connections per worker, with latency measured from the intended send time. The run ended with 4 complete rounds where the plan asked for 5 (why it ended a round short), so each cell has 24 flushes.

Cell p99 inside a flush minus outside Sham reach Verdict
Own core, no sink −8 µs [−27, +11] 20 µs not a finding, inside the 120 µs floor
Own core, statsd −21 µs [−35, −8] 7 µs not a finding, inside the floor
Own core, OTLP −7 µs [−25, +11] 8 µs not a finding, inside the floor
Own core, first 70 ms of a flush, three arms pooled +500 µs [−116, +1,117] 732 µs not resolved
Worker’s core shared with the main thread, no sink +3,547 µs [+3,358, +3,736] 33 µs finding
Worker’s core shared with the main thread, statsd +3,723 µs [+3,498, +3,947] 6 µs finding

p99 latency inside a flush minus outside, in microseconds, 4 rounds, 24 flushes per cell, 95% t intervals, corrected over the six p99 rows. Every row is Measured. “Sham reach” is the largest contrast the same analysis finds when the flush windows are shifted to times with no flush. A finding needs an interval that excludes zero and a mean above the larger of the reach and the 120 µs floor. The shared-core rows pin the main thread onto one worker’s CPU, the worst case without a CPU quota.

Main thread on its own core

All three contrasts are inside the floor. The statsd interval excludes zero on the side of “faster inside a flush”; at 21 µs under a 120 µs floor it is not a finding. Outside a flush, p99 was 671 µs with no sink, 834 µs with statsd and 680 µs with OTLP.

One observation is exploratory, chosen after seeing the data. A probe slower than 1.5 ms appeared at 4, 9 and 9 of 24 flush starts (no sink, statsd, OTLP), against 0 of 385, 200 and 291 sham windows. The tested form of that question, the pooled p99 contrast for the first 70 ms of a flush, is not resolved. The counts suggest a short burst of worker-side work at a flush start without establishing it. A likely source is the work posted to every worker when a flush begins: each worker walks its own thread-local histograms and switches each to its second buffer, and the main thread merges them afterwards. There are 50,000 cluster histograms (five per primed cluster); how many of them each worker holds depends on which worker served which cluster, which we did not count.

Main thread on a worker’s core

Both shared-core rows are findings. During a flush the shared worker waited on the run queue for 269 and 297 ms per second (no sink, statsd) against 1.5 and 2.1 ms outside one. The other three workers did not move: p99 677 against 683 µs with no sink and 841 against 832 µs with statsd, inside against outside. The flush itself got 41% and 51% longer on the shared core.

This shape is a hard pin. We did not run an unpinned main thread or a CPU quota. We expect a larger delay at a higher load; that was not measured.

The admin port during a flush

Admin handlers run on the main thread, so a request to the admin port waits for the flush. /ready was probed every 50 ms. Its longest wait was 0.37 s with no sink, 2.50 s with statsd and 1.32 s with OTLP on the main thread’s own core, and 0.48 s and 3.67 s (no sink, statsd) on the shared core: 0.91 to 0.99 of the flush length in each cell. Of 2,946 probes sent well inside a no-sink or statsd flush, none was answered more than 20 ms before the flush ended. Outside a flush no admin probe took 20 ms (0 of 19,157). These figures are descriptive and belong to 10,000 clusters and 1,180,407 stats.

The smallest stall this run could see

With synthetic stalls added to the recorded data, a stop of all workers for 2 ms at every flush start would have been detected; 1 ms would not. Once per flush, the limit was 3 ms with no sink and 20 ms with OTLP, and with statsd a 20 ms stall was not detected. A stall that happens in fewer than 1 flush in 9 can be missed, and percentiles beyond p99 are not resolved. Every cell also showed single-worker slow events of 5 to 31 ms, in and outside flushes, whose source was not identified.

Data: asset stats-2026-11-data-flush-latency.tar.gz (unpacked: data/stats/flush-latency/); outputs under docs/stats-tables/flush-latency/ (release, tables)

What does turning stats off save per request?

Rejecting every stat in the stats store (reject_all: true) on the official v1.40.2 binary changed worker cycles per request by −1.98% [−2.95, −0.99] at 28 workers and 36% busy, the one cell with a verdict. Per-host stats stay on, so this is a lower bound on what stat updates cost on the request path. Across the other cells the point estimates run from 1.5 to 2% at 36% busy and from 2.3 to 2.6% at 26% busy (4 to 28 workers; the 1-worker cell, at about 30% busy, read 2.67%); the difference between the two loads is not resolved. The count of instructions removed is the steadier signal: about 3.9% of user instructions per request in every cell.

Why this is a lower bound

“Off” here is stats_config with stats_matcher set to reject_all: true, the only difference between the two bootstrap files; the binary is the same. In v1.40.2 the check is in the store’s scope class: ThreadLocalStoreImpl::ScopeImpl::counterFromTaggedName() starts with if (scopeRejectsAll()) and returns the store’s null_counter_ (source/common/stats/thread_local_store.cc). Gauges, histograms and text readouts have the same check, with gauges created as ImportMode::HiddenAccumulate exempt. Each leg checked that the store’s stats were absent at its end.

Several things stay on. The per-host stats are not store stats (HostStats in envoy/upstream/host_description.h: counters such as rq_total and rq_success, gauges such as rq_active), and with one upstream host every worker writes the same host’s stats. The call sites still run and call into a null stat. And names are still built for dynamically named stats: the response-code stats join their name (StatNameJoiner in source/common/http/codes.cc) before they ask the scope, so that work runs with stats rejected too.

The checklist’s router dynamic_stats: false row, −2.92% [−3.65, −2.19], is a different setting and a different measure: total proxy cycles per request, 4 workers, 4 KB proxied responses at 5,200 req/s, one session on 29 November. By our reading of the v1.40.2 router, that setting skips the response-code and response-timing stat calls before any name is built, and with them a call to the outlier detector. All of that still runs when the store’s stats are rejected. The two settings were never compared in one run. The same session’s stats_matcher inclusion list read +0.19% [−0.54, +0.94], no difference resolved.

In this configuration the arm removes 17 store-stat operations per request: 14 counter increments and 3 histogram samples. The 14 is counted. The 3 is inferred: the stats dump lists three histograms that take one sample per request, and snapshots counted 2.8 to 3.0 because a snapshot only sees samples after a flush. Gauge updates are not counted.

At 26% and at 36% busy

Worker cycles per request with the store's stats rejected, by worker layout, at 36% and 26% busy At 36% busy, change against the default: 14 workers on one socket minus 1.47 percent, interval minus 2.38 to minus 0.55, no verdict; 14 workers over two sockets minus 1.99, interval minus 2.84 to minus 1.13, no verdict; 28 workers minus 1.98, interval minus 2.95 to minus 0.99, with a verdict. At 26% busy, share of worker cycles: 14 workers on one socket 2.29 percent, interval 1.56 to 3.03; 14 workers over two sockets 2.64, interval 1.68 to 3.60; 28 workers 2.28, interval 1.40 to 3.16, the last with a same-build repeat that missed its gate. 36% busy: change in worker cycles per request, stats rejected against default Under 1%: not a finding from one run 14 workers, one socket 14 workers, one socket: −1.47% [−2.38, −0.55], no verdict 14 workers, two sockets 14 workers, two sockets: −1.99% [−2.84, −1.13], no verdict 28 workers 28 workers: −1.98% [−2.95, −0.99], measured −4% −3% −2% −1% 0 26% busy: share of worker cycles per request, default minus stats rejected Under 1%: not a finding from one run 14 workers, one socket 14 workers, one socket: 2.29% [1.56, 3.03], same-build repeat passed 14 workers, two sockets 14 workers, two sockets: 2.64% [1.68, 3.60], same-build repeat passed 28 workers 28 workers: 2.28% [1.40, 3.16], same-build repeat missed its gate 0 1% 2% 3% 4% Filled marker: the same-build repeat passed its 1% gate. Hollow: it missed.

36% busy: change in worker cycles per request, stats rejected against default

36% busy: change in worker cycles per request, stats rejected against default At 36% busy, change against the default: 14 workers on one socket minus 1.47 percent, interval minus 2.38 to minus 0.55, no verdict; 14 workers over two sockets minus 1.99, interval minus 2.84 to minus 1.13, no verdict; 28 workers minus 1.98, interval minus 2.95 to minus 0.99, with a verdict. Under 1%: not a finding from one run Under 1%: not a finding from one run Under 1%: not a finding from one run 14 workers, one socket 14 workers, one socket: −1.47% [−2.38, −0.55], no verdict 14 workers, two sockets 14 workers, two sockets: −1.99% [−2.84, −1.13], no verdict 28 workers 28 workers: −1.98% [−2.95, −0.99], measured −4% −3% −2% −1% 0

26% busy: share of worker cycles per request, default minus stats rejected

26% busy: share of worker cycles per request, default minus stats rejected At 26% busy, share of worker cycles: 14 workers on one socket 2.29 percent, interval 1.56 to 3.03; 14 workers over two sockets 2.64, interval 1.68 to 3.60; 28 workers 2.28, interval 1.40 to 3.16, the last with a same-build repeat that missed its gate. Under 1%: not a finding from one run Under 1%: not a finding from one run Under 1%: not a finding from one run 14 workers, one socket 14 workers, one socket: 2.29% [1.56, 3.03], same-build repeat passed 14 workers, two sockets 14 workers, two sockets: 2.64% [1.68, 3.60], same-build repeat passed 28 workers 28 workers: 2.28% [1.40, 3.16], same-build repeat missed its gate 0 1% 2% 3% 4%

Filled marker: the same-build repeat passed its 1% gate. Hollow: it missed. The shaded band is the 1% floor.

Worker cycles per request with the store's stats rejected (reject_all) against the default, official Envoy v1.40.2, 15 rounds, 95% intervals. Top panel, 36% busy: the change against the default, where negative means cheaper without the stats; widened intervals. Bottom panel, 26% busy: the default minus the rejected arm as a share of the default, where positive is the stats' share; plain t intervals. Per-host stats stay on, so every row is a lower bound. The shaded band is the 1% floor.
Load Workers Result Same-build repeat, half-width Basis
36% busy 14, one socket −1.47% [−2.38, −0.55], 14 rounds 1.11%, missed No verdict
36% busy 14, two sockets −1.99% [−2.84, −1.13] 1.19%, missed No verdict
36% busy 28 −1.98% [−2.95, −0.99] 0.62%, passed Measured; small, the near end of the interval is under 1%
26% busy 14, one socket 2.29% [1.56, 3.03] of worker cycles 0.88%, passed Measured, descriptive
26% busy 14, two sockets 2.64% [1.68, 3.60] 0.82%, passed Measured, descriptive
26% busy 28 2.28% [1.40, 3.16] 1.02%, missed No verdict
26% busy 4 2.32% [1.23, 3.41] 1.24%, missed No verdict
26% busy 1 2.67% [−1.20, 6.54] 3.19%, missed No verdict

15 rounds unless a row says otherwise. Two sign conventions, one per load. The 36% rows are the change in worker cycles per request with the stats rejected, against the default (negative: cheaper without the stats), with widened 95% intervals. The 26% rows are the default minus the rejected arm as a share of the default’s worker cycles (positive: the stats cost that share), with plain t intervals. The 26% rows were analysed as the plan had them, as descriptive levels; the 36% rows were given verdicts as described under How we measured. Every row is a lower bound: per-host stats stay on. The 1-worker cell ran at about 30% busy.

The rule cost two cells at 36% busy. At 14 workers on one socket the same-build repeat’s half-width was 1.11%; without one round it would have been 0.89% and the cell would have passed. The rule was not changed after the data. The 28-worker cell was lower with the stats rejected in 15 of 15 rounds, by 10.5k cycles per request [6.2, 14.8] on a base of 532.6k.

Rejecting the store’s stats removed 6.31k, 6.35k and 6.35k user instructions per request at 36% busy; as a share of user instructions that is 3.88% to 3.91%, within 0.04 points of the same share at 26% busy. The 36% instruction rows are exploratory, a secondary measure.

On the official arm64 release binary, on the Arm VM, the store’s stats cost 3.39% [2.67, 4.11] of worker cycles per request at 12 workers (default against rejected; 20 rounds, measured, a lower bound); its denominator differs from the server’s, so the two percentages cannot be compared. Its data: asset stats-2026-11-data-arm-codegen.tar.gz (unpacked: data/stats/arm-codegen/); table docs/stats-tables/arm-codegen/codegen.md (release, codegen.md)

Data: asset stats-2026-11-data-multi-worker.tar.gz (unpacked: data/stats/multi-worker/); table docs/stats-tables/multi-worker/u.md. Asset stats-2026-11-data-multi-worker-high-load.tar.gz (unpacked: data/stats/multi-worker-high-load/); table docs/stats-tables/multi-worker-high-load/u-hi.md (release, u.md, u-hi.md)

Do shared counters cost more with more workers?

Not resolved. From 14 to 28 workers, across two sockets and from 26% to 36% busy, no growth of the store-stats cost was shown, and none was excluded at this precision. Against per-connection counters no sharing cost was resolved either. No cell of that run has a verdict, so it gives no bound under our own rule; its intervals reach +1.3% to +2.9% of worker cycles at 64 to 128 extra updates per request.

From 14 to 28 workers and across sockets

Contrast Estimate Load Basis
14 workers over two sockets minus 14 on one socket +2.00k cycles per request [−4.74, +8.74] 26% busy Not resolved; both cells passed their A/A
28 workers minus 1 worker −3.90k cycles per request [−29.82, +22.02] 26% busy No verdict
28 workers minus 4 workers −0.42k cycles per request [−8.06, +7.22] 26% busy Exploratory; no verdict
28 workers minus 14 on one socket +0.61 points [−0.58, +1.79], 14 rounds 36% busy No verdict
14 over two sockets minus 14 on one socket +0.47 points [−0.29, +1.23], 14 rounds 36% busy No verdict
36% busy minus 26% busy, by layout −0.84, −0.67 and −0.31 points; with the between-session term [−2.17, +0.49], [−2.08, +0.75], [−1.76, +1.14] two sessions Exploratory; not resolved

Differences in the store-stats cost between cells. Positive: the store’s stats cost more in the first-named cell. 15 rounds unless stated; 95% intervals. “Points” are percentage points of worker cycles per request. The by-layout row lists 14 workers on one socket, 14 over two sockets, 28 workers.

The growth test we planned, from 1 worker to 28, has no verdict. The 1-worker cell failed its same-build repeat (half-width 3.19%): 4 of its 45 legs sat 7% to 17% below the cell’s median, cause not established. The plan does not allow another baseline cell after the data. With 4 workers as the baseline anyway, which is exploratory and uses two cells that both missed the same-build gate, the interval reaches +7.2k cycles per request: 1.3% of worker cycles, or about half of the 13k cost in question, too wide to bound it.

The cross-socket interval at 26% busy allows anything from −0.8% to +1.5% of the cell’s cycles, which is about a third less to two thirds more than the cost itself. The two loads were measured in separate sessions two days apart, and in each layout one of the two cells had failed its A/A gate; under the stricter form, which uses each session’s own A/A, that comparison cannot exclude a doubling.

The design has a limit too: at 14 and at 28 workers every store counter is already shared by all workers, so these contrasts measure growth between two shared states. The next run was built to measure the cost of sharing itself.

Shared against per-connection counters

Envoy’s stats access logger (envoy.extensions.access_loggers.stats.v3.Config) adds a chosen number of counter increments per request, with a tag. Tagged by the local port, all workers write the same counters; tagged by the client’s port, each downstream connection gets its own set. The run used 1,500 requests per second per worker, and with the extra increments the arms ran 42% to 47% busy.

Layout Extra increments per request Shared against per-connection Rounds Basis
14 workers, one socket 128 +0.27% [−2.36, +2.89] 5 No verdict
14 workers, one socket 64 +0.53% [−0.26, +1.32] 6 No verdict
14 workers, two sockets 128 +0.04% [−1.30, +1.38] 6 No verdict
28 workers 64 +0.30% [−0.70, +1.31] 6 No verdict

Mean per-round log ratio of worker cycles per request, shared over per-connection, as a percentage. Each interval is the wider of the plain 95% t interval and the form with the between-session term. No row has a verdict: the same-arm repeat had a half-width of 1.28% to 1.61% against the 1% gate. The base includes the logger’s own cost (in a one-round pilot, 617k and 694k worker cycles per request at 64 and 128 increments against 545k without it), so these percentages are not comparable with the stats-off rows.

This was a short run by decision: 6 rounds where the other runs have 15, with the rule that no rounds are added to rescue a statement. It started without a passing pre-run check (one leg of that check read 0.052 against the 0.05 gate, twice). 8 of 106 legs were invalid, all for other tasks on the proxy’s cores, which leaves the 128-increment comparison on one socket with 5 rounds.

The interval ends are printed for the record. Three more things weaken them, all found by the second analysis after the run.

The same-arm repeat was one-sided. The second per-connection copy read lower than the first in all three layouts (pooled −0.69% [−1.34, −0.04] over 17 rounds), an offset as large as the effects in the table. The arm order was a cyclic shift, so the second copy always ran after the same arm; a carry-over from that leg would look like this, and this design cannot separate the two.

The reference arm has a cost of its own. Per-connection counters are private but do not stay in a worker’s cache. Against a single private counter that does, the per-connection arm cost about 130 cycles more per update. So “shared equals per-connection” means that a shared counter costs as much as a counter outside the worker’s cache.

The 64-increment row depends on which rounds are used. On the 5 rounds it shares with the 128-increment pair, the 64-increment row on one socket reads +0.71% [+0.33, +1.09], and with the between-session term added the interval reaches zero.

Against that cache-resident private counter, a counter written by all workers cost about 140 to 160 cycles more per update on this machine (exploratory, 5 rounds; one of the two shared arms ran 2.03% fewer user instructions). Applied to the plain configuration’s operations per request, the point estimates give about 0.4 to 0.5% of worker cycles (modelled). That range reflects only what is counted: 14 counter increments, or also the 3 histogram samples, which v1.40.2 records into per-thread histograms. The intervals of the per-update price (about 60 to 250 cycles) put the same model at about 0.15% to 0.8%. The model was built after the run, from an exploratory contrast in a cell without a verdict, and the price was measured on 128 increments made in one burst, which may understate what scattered updates pay.

Whether sharing a counter costs anything measurable per request at these loads, and whether that cost stays flat as workers are added, stays open. On this machine the busiest shared line was occupied an estimated 12% to 20% of the time (modelled), short of queuing. A wider machine, or a client setup that reaches a higher load at 28 workers, would reopen the question.

The worst case in a microbenchmark

In a microbenchmark where every thread updates one counter as fast as it can, the update cost 9.28 times [8.49, 10.13] its uncontended cost at 4 threads and 44.4 times [43.4, 45.4] at 19 threads on the bare-metal server (measured; 5 rounds, each the median of 5 repetitions of a 1 s window). That is a worst case for one cache line. The end-to-end runs above stayed far below this regime, which in our reading is why the two sets of results are consistent.

The counter here is a model of the atomics alone, with no Envoy stat code; an increment is three atomic read-modify-write operations. It cost 70.8 cycles per operation with the threads’ counters spaced apart, and 634 and 3,152 cycles when 4 and 19 threads shared one. Those three levels are medians over the 5 rounds; the ratios 9.28 and 44.4 above are means over the rounds of the per-round ratio, so dividing the levels gives slightly different figures. On the x86 VM the real counter, which goes through a scope, read 14.8x [14.1, 15.4] and 27.0x [25.6, 28.3] at 4 and 7 threads.

The first two rounds of these benchmarks were void, and no number from them is used: among other faults, a fixed iteration count per thread let fast threads finish early, which biases the shared-line cost downwards. The timing was rebuilt around a time-bounded window in which no thread stops before all have measured. That came after the plan, so this part was not stated before the runs in the way the rest was.

At the tag, the rendered table dose-2.md prints “5” valid rounds on the 64-increment row on one socket; the estimate uses 6. Its linearity line uses the 5 rounds that row shares with the 128-increment pair. An erratum on the harness’s main branch records both.

Data: the multi-worker and multi-worker-high-load assets named above; asset stats-2026-11-data-contention.tar.gz (unpacked: data/stats/contention/), table docs/stats-tables/contention/dose-2.md; asset stats-2026-11-data-microbenchmarks.tar.gz (unpacked: data/stats/microbenchmarks/), tables under docs/stats-tables/microbenchmarks/ (release, dose-2.md, tables)

Does relaxed memory ordering help?

For stores, yes in a microbenchmark. For counter increments, none that we could resolve: under 1% on the server’s model counter, within 2% on the x86 VM’s, and on the x86 VM’s real counter and on Arm inside intervals that reach 4% to 10%. End to end the effect is modelled at 0.04% of cycles per request at most, so we did not run it.

The idea comes from the issue, where Joshua Marantz lists relaxed ordering as one possible remedy for the reference counts and adds that the stat values themselves could probably tolerate it too. The reference-count part was merged in #46001 and is in v1.40.2. We tested the stat values, in microbenchmarks. Separately, his design document expects the flush’s reference-count cost to be worse on Arm than on x86; that is a statement about the flush, his pull request says he did not measure it, and we did not test it. Whether relaxed ordering of stat updates gains more on Arm was our own question.

Operation x86 Arm VM Basis
Counter increment, model, shared; server, 4 and 19 threads −0.7% [−1.2, −0.3] and −0.5% [−0.7, −0.4] – Measured; under 1%
Counter increment, model, shared; VMs, 4 threads and the top count (7 on x86, 12 on Arm) +0.0% [−0.7, +0.7] and +0.3% [−1.2, +1.7] −0.4% [−4.9, +4.3] and −0.4% [−3.8, +3.1] Measured; not resolved
Counter increment, real counter, shared by 4 and 7 threads +0.7% [−7.7, +9.8] and −0.4% [−4.9, +4.2] (VM) descriptive only Measured (x86); not resolved
Gauge::set, each thread on its own gauge −38.6% [−38.6, −38.6] (VM; the interval is narrower than the rounding) −20.6% (descriptive) Measured (x86)
Gauge::set, shared by 4 and 7 threads −35.4% [−37.9, −32.9] and −32.5% [−36.4, −28.3] (VM) as run: no accepted data; after one timing gate was loosened post-hoc: −19.6% [−29.4, −8.5] at 12 threads (Exploratory) Measured (x86)
Histogram sample, one worker −5.3% [−5.5, −5.1], 149.9 to 142.0 cycles per sample (VM) −0.8% [−1.0, −0.6], 125.7 to 124.7 Measured

Relaxed against the current ordering, cycles per operation, 5 rounds, 95% t intervals. Ratios within one machine only. The Arm real-stat cells are descriptive because their processes missed a timing gate.

For counters, on x86 the instruction count per increment was identical at either ordering (53.44 per operation), and cycles were equal within 0.1% uncontended; we did not disassemble the binaries. On the server’s model counter the intervals exclude zero but stay under 1%, so they are not a finding by our rule.

For gauges and histograms, a store gains. On x86 Gauge::set loses its xchg instruction under relaxed ordering, at an unchanged instruction count. Recording a histogram sample stores the “used” flag, which sinks and the admin endpoint use to skip stats that were never written (statsd, OTLP, /stats?usedonly) and which hot restart uses when handing values to a new process. At the top worker counts (7 on the x86 VM, 15 on the Arm VM) neither histogram cell has a verdict.

The difference between the two VMs in what relaxed ordering does to a shared model counter at 4 threads is +0.44 [−4.13, +5.00] log-percent. These microbenchmarks show no larger gain on Arm, and the interval allows about 5 points in each direction.

End to end, a model from the per-operation gains and the operations per request puts relaxed ordering at 0.00% to 0.04% of cycles per request, depending on the machine (modelled; one input, 12.6 counter increments per request, is a proxy from a profile that is in no published file). Our bar for an end-to-end run, set before the microbenchmarks, was a predicted 0.5%. Under that rule we skipped the end-to-end run of the patched builds. Operation counts showing Gauge::set dominating the store-stat work would reopen it.

The Arm benchmark builds are our own builds from Envoy main, and we did not disassemble them. Main compiles atomics differently from the official v1.40.2 arm64 binary, as the arm64 atomics post shows, so the Arm microbenchmark figures describe our builds.

Data: asset stats-2026-11-data-microbenchmarks.tar.gz (unpacked: data/stats/microbenchmarks/); tables under docs/stats-tables/microbenchmarks/ (release, tables)

Changes we looked at, and the evidence for each

The code candidates are patches on our fork or models in a benchmark; any error in them is ours. Rows are ordered by how much evidence exists, configuration choices first. Whether any code candidate is worth its cost is for Envoy’s maintainers to decide.

Candidate, and what it changes Evidence for Evidence against, or missing Status
Buffered dog_statsd in place of plain statsd. Flush lines are packed into datagrams Added flush time +655 ms against +2,130 ms at 1,180,396 stats (flush table) Under load +17.78% against +19.69% per request, not compared directly (under load). A different sink, with tags config only
OTLP sink in place of statsd. Points are exported over gRPC at each flush Under load +1.66% [+0.69, +2.65] in total, +0.03% on the workers About 1.28 s of main thread per flush at 1,180,396 stats. A collector at its default 4 MiB receive limit rejected 13.9% of the points in our first session config only
Main thread on a core no worker uses. A flush no longer competes with a worker Shared core: +3,547 and +3,723 µs at p99 on that worker; own core: inside the floor (latency) The shared shape is a hard pin, the worst case. An unpinned main thread and a CPU quota were not run. One load, 4 rounds config only
Batched statsd datagrams, a patch of ours on v1.40.2 (tag statsd-batch-2026-11/v2). An opt-in max_bytes_per_datagram field on the plain statsd sink packs each thread’s histogram samples, and the flush’s lines, into datagrams About −8% [−9.2, −7.0] CPU per request against the official binary, both with a plain statsd sink; 1.20 datagrams per request against 4.21. One session on 21 November: 4 workers, 5,200 req/s, 1,000 clusters, 5 s flush interval, loopback (price list) Off by default; the receiver must accept several metrics per datagram, and one lost datagram loses up to 512 bytes of metrics. One session. On loopback the receive path is charged to the proxy; behind a network card we expect a smaller saving. The two arms differ in binary and configuration, because the official binary rejects the field. Plain statsd only own build, measured end to end
Flush path: the approach of #43958, applied by us to main at 5e1439980a. The flush holds scopes in place of stats With no sink, main-thread run time −24.4% at about 118,000 stats and −27.4% at about 1.18 million (widened intervals [−31.7, −16.3] and [−32.2, −22.2]); 5 rounds, 75 of 75 legs valid With a statsd sink no change was measurable (−0.2%, +1.6%, −2.9% at three sizes): the per-line send dominates. The A/A missed its 2% target at every size, and the metric includes main-thread time outside flushes. Holding scopes is not safe by itself: the design document describes a stat released on a worker while the snapshot is in use, and makes API changes a precondition. Our stack ports parts of #44285 for that (the variant that deprecates the shared-pointer accessors) and bounds the snapshot’s lifetime; its commit messages say which sanitizer runs passed, which tests were not run and which gaps are known. We measured speed. The pull request is a draft, closed for inactivity and unmerged own build, flush measured
Test the “used” flag before setting it. An increment skips the flag write when the flag is already set x86 VM, real counter: −28.1% to −28.4% per increment uncontended; −26.3% [−30.2, −22.2] and −27.5% [−30.5, −24.3] shared by 4 and 7 threads A behaviour change where stat eviction is enabled (stats_eviction_interval): eviction is the only caller of markUnused(), and an update that races it may not re-mark the stat. v1.40.2 has a narrower window of the same kind. At defaults the flag is never cleared. Modelled end to end at 0.037% to 0.095% of cycles per request (the low end uses 12.6 counter increments per request, a proxy from a profile that is in no published file and cannot be regenerated), under our 0.5% bar. No end-to-end run microbenchmark only
Relaxed memory ordering for stat values. The ordering argument of the atomics Gauge::set −38.6% on x86; histogram sample −5.3% on x86 and −0.8% on Arm at one worker Counter increments: under 1% or not resolved. No larger gain on Arm: +0.44 [−4.13, +5.00] log-percent. Modelled end to end at 0.00% to 0.04%. No end-to-end run. A ThreadSanitizer run of the series reported two new data races in integration tests that synchronize by polling a stat; the commit message has the record microbenchmark only
One read-modify-write per increment in place of three. Drops pending_increment_ and the flag write Model counter: about two thirds cheaper, shared or not (−66.9% to −72.8% on the server) The flush reads each counter’s delta from pending_increment_ with latch(), and delta-reporting sinks and hot restart depend on it. No Envoy build and no end-to-end figure model only
Per-thread counters. Each worker increments its own cell Model counter: 1.00x at every thread count; −97.1% and −99.4% against the shared counter at 4 and 19 threads on the server For the plain configuration, modelled at about 0.4 to 0.5% of worker cycles on point estimates (about 0.15% to 0.8% with the price’s interval), from a per-update price that is itself exploratory. No Envoy build. This machine could not reach the queuing regime model only

For the plain configuration we did not pursue per-thread counters: the modelled gain, about 0.4 to 0.5% of worker cycles, is below what this method can measure. The microbenchmark percentages are per operation in a loop that does nothing else; the figure to read them against is the lower bound of about 2% of worker cycles for all store stats together. The design document’s own flush benchmark predates the two merged fast paths and times the flush in isolation; our flush row is main-thread time on a running proxy after both.

What we got wrong and how it was caught

Each of these bears on a number above; the two void microbenchmark rounds are told with the worst case. The hub post has the earlier retractions.

The collector that rejected points. The rejected OTLP points had two causes, both ours. We left the collector’s receive limit at its default 4 MiB, and a request of about 10,000 histogram points is about 4.5 MB (inferred; we kept no collector log). And minutes before the session we changed the harness’s evidence check, unreviewed, on a wrong premise: that at this size a flush exports only counters and gauges. A later review by AI agents (multiple independent lenses, top-tier models) rejected the premise, and the second analysis confirmed it from the raw legs: Envoy sent 37 requests per flush, and 31 full requests plus 146 points is exactly the count that arrived. The legs were ruled invalid and the cell was re-run. The truncated reading had been +1,004 ms against +1,013 ms, which does not validate the first legs.

Logins that tripped the idle-core gate. A monitoring loop of ours kept logging in to the test machine about 9 times a minute, and legs kept failing the gate on other tasks using the proxy’s cores. No gate was changed. With the loop stopped, 2 of 54 legs at 28 workers and 1,500 requests per second per worker were invalid, against 7 of 12 with it running. The flush-latency run and the OTLP re-run ran entirely under the loop; both passed their gates and were not re-analysed. The loop explains part of it. At 14 workers on one socket a second source, not identified, accounts for 8 of that run’s 10 invalid legs.

Expectations the runs did not support. We expected relaxed ordering to make counter increments cheaper, and more so on Arm; for counter increments no gain was resolved, and no larger gain on Arm (above). Our plan expected testing the “used” flag first to gain little under contention, because the line is fetched anyway; on the x86 VM’s real counter it gained 26% to 28% when shared. Our plan for the shared-counter run predicted a sharing cost of 1% to 4% on one socket and 4% to 7% across two at 128 increments; it measured +0.27% [−2.36, +2.89] and +0.04% [−1.30, +1.38]: the two-socket prediction lies outside its interval and the one-socket prediction inside; neither cell has a verdict.

A load target we missed. The plan aimed for 60% to 70% busy and the run reached 36%. At 28 workers the client’s connection pool overflows from 2,100 requests per second per worker, and an attempt at 1,800 was stopped with 8 of 15 legs invalid at 28 workers. A different client setup is needed to go higher.

A latency run one round short. Three legs in one cell failed the exact request-count gate by 2, 1 and 1 requests, most likely a request answered after the load generator stopped counting. The legs stayed invalid, which cost two repeat rounds and part of a third. We moved the run’s stop time past the planned one; at the planned stop it would have ended with 2 complete rounds and no verdict. That is a deviation from the plan, and with 4 rounds the intervals are 28% wider.

Where are the code and the data?

The harness code, the configurations, the rendered tables and the checksums of the data are in the harness repository, github.com/We-Amp/envoy-price-list (code under Apache 2.0, data under CC BY 4.0), at the tag stats-2026-11. The raw per-leg records, invalid and superseded legs included, are not in git. They are assets of the release of that tag, one archive per study, on the release page. python3 tools/fetch-stats-data.py downloads them, checks each archive and every file against the checksums in the repository, and unpacks them into data/stats/. docs/stats-study.md has the commands for every study. The second analysis’s scripts are under examples/stats-flush/analysis-* and examples/stats-mt/analysis-*; their outputs are in the archives and under docs/stats-tables/.

Section Release asset, and the path inside it Rendered table in the repository Harness example Envoy binary or source
Sink cost under load; flush cost per sink stats-2026-11-data-sink-types.tar.gz: sink-types/sw/, s-100k/, s-1m/, s-1m-otlp-rerun/ outputs under docs/stats-tables/sink-types/ examples/stats-flush official v1.40.2
Earlier sink session; the own-build flush comparison stats-2026-11-data-sink-flush-cost.tar.gz: sink-flush-cost/m-*/, mfix-*/ docs/stats-tables/sink-flush-cost/tables.md examples/stats-flush official v1.40.2; upstream main 5e1439980a and tag stats-2026-11/sink-fix
Flush and request latency stats-2026-11-data-flush-latency.tar.gz: flush-latency/lat/ outputs under docs/stats-tables/flush-latency/ examples/stats-flush official v1.40.2
Stats off, 26% busy stats-2026-11-data-multi-worker.tar.gz: multi-worker/u/ docs/stats-tables/multi-worker/u.md examples/stats-mt official v1.40.2
Stats off, 36% busy stats-2026-11-data-multi-worker-high-load.tar.gz: multi-worker-high-load/u-hi-1500/ docs/stats-tables/multi-worker-high-load/u-hi.md examples/stats-mt official v1.40.2
Shared against per-connection counters stats-2026-11-data-contention.tar.gz: contention/dose-2/, dose-evidence-2/ docs/stats-tables/contention/dose-2.md examples/stats-mt official v1.40.2, configuration only
Microbenchmarks stats-2026-11-data-microbenchmarks.tar.gz: microbenchmarks/bench-x86_64/, x86-vm/, arm-vm/, arm-vm-b/ tables under docs/stats-tables/microbenchmarks/ examples/stats-mt tags stats-2026-11/bench-fix, bench-fix-relaxed, bench-fix-relaxed-p1
Stats off on arm64 stats-2026-11-data-arm-codegen.tar.gz: arm-codegen/arm-vm/ docs/stats-tables/arm-codegen/codegen.md examples/stats-mt official v1.40.2 arm64

The Envoy sources are tags on our fork, stats-2026-11/sink-fix, stats-2026-11/bench-fix, stats-2026-11/bench-fix-relaxed and stats-2026-11/bench-fix-relaxed-p1 (the flush stack as one diff), all on upstream main at 5e1439980a (17 November 2026). The benchmark tags stack: relaxed ordering sits on the flush stack plus the benchmarks, and the “used” flag test sits on relaxed ordering.

A reproduction will not match in three respects. The published Envoy commits are a cleaned copy of the commits we measured: the same tree for the flush stack, and five comment lines (in four places) different in two test-only benchmark files for the benchmark tags. Rebuilt from the published tags on an x86-64 build machine with the same toolchain, the benchmark binaries of the three microbenchmark tags and the flush benchmark have the same SHA-256 as the ones we measured. The published harness history is a cleaned copy too. We replaced fixed strings in comments, docstrings, log messages, the notes of the example configs, one README paragraph and the commit messages of older commits, and renamed one test class. Every file that differs equals the measured file with the listed replacements applied. The table and analysis commands we ran with the harness of both commits gave identical output, apart from one reworded label line. The data records the measured commit ids of both; with few exceptions (the upstream base among them) those ids are not in the public histories. Two mapping files, docs/stats-data/envoy-commit-map.md and docs/stats-data/harness-commit-map.md, pair measured and published ids and state what differs (envoy-commit-map.md, harness-commit-map.md). And a rebuilt binary will not be bit-identical to ours, because Envoy embeds its source revision; the harness configurations pin our binaries by hash, so a reproduction pins its own. The build options are in examples/stats-mt/BUILDING.md (BUILDING.md).

Issues are off on the fork. Corrections go to the harness’s issue tracker.

Credit

Envoy’s stats subsystem is the work of its contributors, among them ebm and davidvo-lyft, whose merged fast paths (#45821, #46001) the flush figures already include.

The flush-path candidate and the suggestion to relax the ordering of stat values are Joshua Marantz’s: the design document Improving Stats Sink Efficiency, the issue #43836, and the draft pull requests #43958, #44031 and #44285. Five commits of the flush stack on our fork are ports of #44285 and keep his authorship; five more adapt code or a rule from his pull requests, as their messages say. Those pull requests were closed unmerged; the stack lives on our fork.

The ports, the benchmarks, the measurements and any error in them are ours.

← All writing