From 1e71cdae5b77679152deba09abd7d877ecdf8029 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Wed, 29 May 2024 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?dex:=20=F0=9F=AA=A6=20record=20duration=20of=20?= =?UTF-8?q?dead-end=20path=20search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/dex/src/component/router/path_search.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/core/component/dex/src/component/router/path_search.rs b/crates/core/component/dex/src/component/router/path_search.rs index 3fffa26261..e44e46cd9f 100644 --- a/crates/core/component/dex/src/component/router/path_search.rs +++ b/crates/core/component/dex/src/component/router/path_search.rs @@ -34,8 +34,13 @@ pub trait PathSearch: StateRead + Clone + 'static { // Initialize some metrics for calculating time spent on path searching // vs route filling. We use vecs so we can count across iterations of the loop. - let path_start = std::time::Instant::now(); tracing::debug!(?src, ?dst, ?max_hops, "searching for path"); + let path_start = std::time::Instant::now(); + let record_duration = || { + use crate::component::metrics::DEX_PATH_SEARCH_DURATION; + let elapsed = path_start.elapsed(); + metrics::histogram!(DEX_PATH_SEARCH_DURATION).record(elapsed); + }; // Work in a new stack of state changes, which we can completely discard // at the end of routing @@ -49,14 +54,14 @@ pub trait PathSearch: StateRead + Clone + 'static { let entry = cache.lock().0.remove(&dst); let Some(PathEntry { path, spill, .. }) = entry else { + record_duration(); return Ok((None, None)); }; let nodes = path.nodes; let spill_price = spill.map(|p| p.price); tracing::debug!(price = %path.price, spill_price = %spill_price.unwrap_or_else(|| 0u64.into()), ?src, ?nodes, "found path"); - metrics::histogram!(crate::component::metrics::DEX_PATH_SEARCH_DURATION) - .record(path_start.elapsed()); + record_duration(); match price_limit { // Note: previously, this branch was a load-bearing termination condition, primarily