From 9af60b298b0632757cab6a9d74543cdefd767ad5 Mon Sep 17 00:00:00 2001 From: Florent Tapponnier Date: Sun, 12 Jul 2026 17:24:53 +0200 Subject: [PATCH] rpc-keyed harness: record sub-millisecond latency without truncation time.Duration.Milliseconds() returns int64 and truncates every probe under 1 ms to zero. QuickNode is measured via the Mobula shared paid fleet whose endpoints are peer-adjacent to the harness (short RTT + HTTP keep-alive), so a significant share of successful probes returned in ~0.3 to 0.9 ms and were recorded as 0 ms in Prometheus. The 24h aggregate on the BNB + US-East cell landed at effectively 0 ms and rendered as 'QuickNode leads at 0 ms' on /benchmarks/rpc-keyed-latency?chain=bnb®ion=us-east. Fix: latencyMs = float64(time.Since(start).Nanoseconds()) / 1e6. Same wall-clock delta, real precision preserved down to microsecond granularity. Every other provider stays within noise (their probes were already above 1 ms so the truncation never bit them). Requires a Railway harness rebuild + redeploy to take effect on staging and production (bench 069 runs on Railway, not the shared worker VPS). The materialized store will catch up on the next 24h window after redeploy. --- harnesses/rpc-keyed-latency/cmd/script/probe.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/harnesses/rpc-keyed-latency/cmd/script/probe.go b/harnesses/rpc-keyed-latency/cmd/script/probe.go index d9e944e9..28d0821a 100644 --- a/harnesses/rpc-keyed-latency/cmd/script/probe.go +++ b/harnesses/rpc-keyed-latency/cmd/script/probe.go @@ -127,7 +127,15 @@ func doPost(ctx context.Context, url string, body []byte) (raw []byte, latencyMs start := time.Now() resp, err := client.Do(req) - latencyMs = float64(time.Since(start).Milliseconds()) + // Use nanoseconds and convert to a float millisecond so sub-1ms probes + // are recorded with real precision. time.Duration.Milliseconds() is an + // int64 and truncates every measurement under 1 ms to zero, which + // systematically under-reports latency for providers whose endpoint + // is peer-adjacent to the harness (e.g. QuickNode via the Mobula + // shared fleet: sub-millisecond round-trips truncated to 0 dragged + // the 24h aggregate down to a nonsensical 0 ms on the BNB + US-East + // cell, then rendered as "QuickNode leads at 0 ms" on the UI). + latencyMs = float64(time.Since(start).Nanoseconds()) / 1e6 if err != nil { if ctx.Err() != nil || strings.Contains(err.Error(), "deadline exceeded") || strings.Contains(err.Error(), "Timeout") { return nil, latencyMs, "timeout", err