From 8eed36addc69043810c67acf31f612b52bb87e7f Mon Sep 17 00:00:00 2001 From: Xun Li Date: Wed, 1 Feb 2023 11:39:38 -0800 Subject: [PATCH] Only log duration if we need to wait for effects (#7969) --- .../sui-core/src/authority/authority_notify_read.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/sui-core/src/authority/authority_notify_read.rs b/crates/sui-core/src/authority/authority_notify_read.rs index bb8aeede8a752..698b9c8b540bf 100644 --- a/crates/sui-core/src/authority/authority_notify_read.rs +++ b/crates/sui-core/src/authority/authority_notify_read.rs @@ -189,14 +189,17 @@ impl EffectsNotifyRead for Arc { // We need to register waiters _before_ reading from the database to avoid race conditions let registrations = self.effects_notify_read.register_all(digests.clone()); let effects = EffectsStore::get_effects(self, digests.iter())?; - // Zipping together registrations and effects ensures returned order is the same as order of digests + let mut needs_wait = false; let mut results: FuturesUnordered<_> = effects .into_iter() .zip(registrations.into_iter()) .map(|(e, r)| match e { // Note that Some() clause also drops registration that is already fulfilled Some(ready) => Either::Left(futures::future::ready(ready)), - None => Either::Right(r), + None => { + needs_wait = true; + Either::Right(r) + } }) .collect(); let mut effects_map = HashMap::new(); @@ -205,7 +208,11 @@ impl EffectsNotifyRead for Arc { last_finished = Some(finished.transaction_digest); effects_map.insert(finished.transaction_digest, finished); } - debug!(duration=?timer.elapsed(), ?last_finished, "Finished notify_read_effects"); + if needs_wait { + // Only log the duration if we ended up waiting. + debug!(duration=?timer.elapsed(), ?last_finished, "Finished notify_read_effects"); + } + // Map from digests to ensures returned order is the same as order of digests Ok(digests .iter() .map(|d| {