From 77c9b0ab126eed710eeb9abe6f535e7f9e68c213 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 23 May 2023 14:52:45 -0700 Subject: [PATCH] peak latency instead of head latency --- web3_proxy/src/rpcs/one.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/web3_proxy/src/rpcs/one.rs b/web3_proxy/src/rpcs/one.rs index e3e3b0ea..89825e29 100644 --- a/web3_proxy/src/rpcs/one.rs +++ b/web3_proxy/src/rpcs/one.rs @@ -227,18 +227,16 @@ impl Web3Rpc { } pub fn peak_ewma(&self) -> OrderedFloat { - // TODO: bug inside peak ewma somewhere. possible with atomics being relaxed or the conversion to pair and back - // let peak_latency = if let Some(peak_latency) = self.peak_latency.as_ref() { - // peak_latency.latency().as_secs_f64() - // } else { - // 0.0 - // }; - let head_latency = self.head_latency.read().value(); + let peak_latency = if let Some(peak_latency) = self.peak_latency.as_ref() { + peak_latency.latency().as_secs_f64() + } else { + 1.0 + }; // TODO: what ordering? let active_requests = self.active_requests.load(atomic::Ordering::Acquire) as f64 + 1.0; - OrderedFloat(head_latency * active_requests) + OrderedFloat(peak_latency * active_requests) } // TODO: would be great if rpcs exposed this. see https://github.com/ledgerwatch/erigon/issues/6391