From 3cea4c3123b3ef3fdd8ea796fffc1fd0d8814473 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 12 May 2023 22:18:19 -0700 Subject: [PATCH] update peak_ewma to use request latency and fix off by one --- web3_proxy/src/rpcs/one.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web3_proxy/src/rpcs/one.rs b/web3_proxy/src/rpcs/one.rs index 01575384..597263cd 100644 --- a/web3_proxy/src/rpcs/one.rs +++ b/web3_proxy/src/rpcs/one.rs @@ -237,14 +237,14 @@ impl Web3Rpc { pub fn peak_ewma(&self) -> OrderedFloat { // TODO: use request instead of head latency? that was killing perf though - let head_ewma = self.head_latency.read().value(); + let peak_latency = self.peak_latency.as_ref().unwrap().latency().as_secs_f64(); // TODO: what ordering? - let active_requests = self.active_requests.load(atomic::Ordering::Relaxed) as f64; + let active_requests = self.active_requests.load(atomic::Ordering::Relaxed) as f64 + 1.0; // TODO: i'm not sure head * active is exactly right. but we'll see // TODO: i don't think this actually counts as peak. investigate with atomics.rs and peak_ewma.rs - OrderedFloat(head_ewma * active_requests) + OrderedFloat(peak_latency * active_requests) } // TODO: would be great if rpcs exposed this. see https://github.com/ledgerwatch/erigon/issues/6391