Early return if no global checkpoint listeners (#53036)
When notifying global checkpoint listeners, we have an opportunity to early return if there are not any registered listeners. This is important since it saves some allocations, and also saves forking some empty work to another thread. This commit adds an early return from notifying listeners if there are not any registered.
This commit is contained in:
parent
5cffa14f45
commit
a154f9c657
|
@ -195,6 +195,11 @@ public class GlobalCheckpointListeners implements Closeable {
|
|||
assert Thread.holdsLock(this) : Thread.currentThread();
|
||||
assertNotification(globalCheckpoint, e);
|
||||
|
||||
// early return if there are no listeners
|
||||
if (listeners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<GlobalCheckpointListener, Tuple<Long, ScheduledFuture<?>>> listenersToNotify;
|
||||
if (globalCheckpoint != UNASSIGNED_SEQ_NO) {
|
||||
listenersToNotify =
|
||||
|
|
Loading…
Reference in New Issue