From 7372312a73067b1cd8c4945a22ea838a49d8d5d4 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 22 Nov 2024 15:29:49 +0200 Subject: [PATCH] Avoid unnecessary send_replace calls in seqwait (#9852) The notifications need to be sent whenever the waiters heap changes, per the comment in `update_status`. But if 'advance' is called when there are no waiters, or the new LSN is lower than the waiters so that no one needs to be woken up, there's no need to send notifications. This saves some CPU cycles in the common case that there are no waiters. --- libs/utils/src/seqwait.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/utils/src/seqwait.rs b/libs/utils/src/seqwait.rs index 375b227b99..d99dc25769 100644 --- a/libs/utils/src/seqwait.rs +++ b/libs/utils/src/seqwait.rs @@ -83,7 +83,9 @@ where } wake_these.push(self.heap.pop().unwrap().wake_channel); } - self.update_status(); + if !wake_these.is_empty() { + self.update_status(); + } wake_these }