Skip to content

Commit

Permalink
Only log duration if we need to wait for effects (MystenLabs#7969)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind authored Feb 1, 2023
1 parent 54c282b commit 8eed36a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/sui-core/src/authority/authority_notify_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,17 @@ impl EffectsNotifyRead for Arc<AuthorityStore> {
// 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();
Expand All @@ -205,7 +208,11 @@ impl EffectsNotifyRead for Arc<AuthorityStore> {
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| {
Expand Down

0 comments on commit 8eed36a

Please sign in to comment.