The cost of metrics: nothing we can measure when off, a few percent on the cheapest calls when on
TL;DR
A node that serves traffic needs metrics, and metrics are not free. On 2026-11-05 and 2026-11-06 we measured the Prometheus endpoint of the 1.0 line. The endpoint is off by default. Then a call does one relaxed load and reads no extra clock. The data show no cost above about 3% of JSON-RPC throughput. With the endpoint on, a replay of 290 Hoodi blocks found no cost above about 5% of the newPayload time. The counter updates of one call take 18.4 ns. The cheapest JSON-RPC calls, eth_chainId and eth_getBalance, lost 2% to 11% of their throughput. Most of that comes from two clock reads on a machine with a slow clock source. Before that, an independent review found a problem in the first version. It counted every call on one shared group of counters, also with the endpoint off: 950 ns per call at 16 threads. We changed it to 16 groups per method, each on its own cache lines. This is work on the development line toward 1.0, not a release.
An operator who runs a node for others wants to see it: how many
blocks, how long each one took, how many calls of each method, how many
errors. For 1.0 we added a Prometheus endpoint with the option
--metrics. The question for this post is simple. What does a node pay
for it?
The answer has three parts: off, on for blocks, and on for JSON-RPC. And there is a fourth part that came first: the version that a review stopped.
This is work on the development line toward 1.0. It is not in a release yet.
How the metrics work
The engine counts each engine_newPayload and engine_forkchoiceUpdated
call by its answer, and it puts the time of the call into a histogram.
For an executed block it also adds the gas, the execution time and the
state root time. Each update is a relaxed atomic add or store on fixed
memory, with no lock. The node writes the text of the metrics only when
a scraper asks for it, on the thread of the endpoint. The hot path never
formats text.
The first version, and the review that stopped it
The first version counted every JSON-RPC call on one shared group of counters per method. It also read the clock two times per call. And it did both with the endpoint off.
An independent review measured it with a small probe: 32 ns per call on one thread, and about 950 ns per call at 16 threads, because the threads fight for the same cache lines. On top of that came about 4.1 µs for the two clock reads on this machine. A node that does not use metrics should not pay for them.
The fix has two parts:
- The counters count only while the endpoint runs. Without it, a call does one relaxed load and no clock read.
- Each method has 16 groups of counters, each on its own cache lines. A thread always adds to the same group, and a scrape sums the groups.
Then we measured again.
Off: no cost that the data can show
With the metrics off, the new build ran at 0.9738 to 1.0139 of the throughput of the build before the metrics.
The A/A control, the same build against itself, gave 0.9768 to 1.0242. So the off path sits inside the band that the method makes on its own. Five of the six medians are below 1, and one interval does not include 1. I do not hide that: it is a hint of a small cost. But it is the same size as the noise. What the data can say is: no cost above about 3%. They cannot show a smaller cost, and they do not prove zero.
On, for blocks: no cost above about 5%
| newPayload, 290 blocks | Median of per-block ratios (95%) | Ratio of sums (95%) |
|---|---|---|
| A2/A, the A/A control | 0.9742 (0.9599 to 0.9878) | 1.0495 |
| B/A, metrics on | 1.0164 (0.9961 to 1.0285) | 1.0058 |
| B/A2, metrics on | 1.0373 (1.0227 to 1.0485) | 0.9584 |
Look at the first row. Two runs of the same build differ by 2.6% by the median ratio and by 5% by the ratio of sums, and the interval of the median does not include 1. That is a systematic difference between arms that the bootstrap over blocks cannot see, because it does not resample the runs. With a control of that size, B/A2 at 1.0373 does not give the cost of the metrics. It means: no cost above about 5% of the block time, and nothing smaller can be shown.
A smaller experiment gives the expected size. A loop of the metrics work of one call, on one pinned core: the counter updates take 18.4 ns. A newPayload call takes about 10 ms here. The counter work and one clock read are less than 0.02% of that. That is an estimate from the loop, not a result of the replay, and I label it so.
On, for JSON-RPC: 2% to 11% on the cheapest calls
With the metrics on, the cheapest calls lost about 2% to 11% of their throughput.
| Row | Throughput lost with the metrics on, against off |
|---|---|
| eth_chainId, 16 threads | 9.6 % |
| eth_chainId, 64 threads | 6.1 % |
| eth_chainId, 256 threads | 1.8 % |
| eth_getBalance, 16 threads | 7.6 % |
| eth_getBalance, 64 threads | 10.7 % |
| eth_getBalance, 256 threads | 5.7 % |
| Method, threads | Calls per second, off | Calls per second, on | on/off (95%) |
|---|---|---|---|
eth_chainId, 16 |
1 080 216 | 1 041 050 | 0.9038 (0.8338 to 1.1543) |
eth_chainId, 64 |
1 115 128 | 1 021 046 | 0.9390 (0.8675 to 1.0105) |
eth_chainId, 256 |
1 095 688 | 1 083 868 | 0.9816 (0.9492 to 1.0243) |
eth_getBalance, 16 |
1 045 022 | 937 819 | 0.9237 (0.8242 to 1.0221) |
eth_getBalance, 64 |
1 029 776 | 910 799 | 0.8926 (0.8356 to 0.9910) |
eth_getBalance, 256 |
1 051 504 | 993 165 | 0.9432 (0.9110 to 0.9743) |
All six ratios are below 1, in this run and in the first run (0.9095 to 0.9799). So the direction is clear, even where a single interval includes 1.
Why does a counter update of 18.4 ns take up to 11% of a call? Because of the clock. This machine uses the HPET clock source, where one clock read costs about 1.4 µs. A call with the metrics on reads the clock two more times. With two clock reads, the loop of the metrics work took 2 904 ns, and nearly all of that is the clock. On a machine with the TSC clock source a read takes some tens of nanoseconds. We did not measure such a machine for this record, so I do not give a number for it.
The loss is a fixed amount of work per call. A heavier call, such as a
trace or a large eth_getLogs, loses a smaller part of its time. These
two methods are about the cheapest calls that a node can serve, so they
show the worst case.
The decision
Kept, with the metrics off by default. An operator who wants them turns them on and pays a few percent on the cheapest calls on a machine like this one, and less on a machine with a fast clock source. An operator who does not want them pays nothing that we can measure.
What this does not show
- A loaded desktop. The load during the JSON-RPC runs was high, and the 256-thread runs add to it. This is why the intervals are wide.
- One clock source. The HPET numbers are the expensive case. A TSC host is not measured.
- Small blocks. The Hoodi blocks of the replay take about 10 ms. The cost of the metrics does not grow with the block, so on larger blocks its share is smaller.
- The engine port. The replay calls the engine in the process, not over HTTP. The only change in the HTTP server is one branch for the GET mode, which the engine port does not use.
How to turn the metrics on is in the monitoring page when 1.0 ships. The plan for 1.0 is on the roadmap.