From f4595138eb29ec95958d9d55b95cc716b2fd692e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 30 Mar 2015 15:59:54 +0200 Subject: [PATCH 1/1] Tune NotificationRouter wait strategy CPU traces show we are seeing NotificationRouter spin for more work even when there are no notifications being generated. Change the strategy so we end up block the thread after a period of spinning/yielding. The default spin period is set to 1ms, followed by 30ms of yielding, followed by a block. This should provide reasonable throughput on notification-heavy workloads as well as not waste a lot of CPU when there are no notifications. Change-Id: Ia1de5ff2616392609a0868b9b8ba3bce15baa105 Signed-off-by: Robert Varga --- .../md/sal/dom/broker/impl/DOMNotificationRouter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java index b9972fc0a0..e814dd2541 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java @@ -17,7 +17,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.lmax.disruptor.EventHandler; import com.lmax.disruptor.InsufficientCapacityException; -import com.lmax.disruptor.SleepingWaitStrategy; +import com.lmax.disruptor.PhasedBackoffWaitStrategy; import com.lmax.disruptor.WaitStrategy; import com.lmax.disruptor.dsl.Disruptor; import com.lmax.disruptor.dsl.ProducerType; @@ -50,7 +50,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; */ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificationPublishService, DOMNotificationService { private static final ListenableFuture NO_LISTENERS = Futures.immediateFuture(null); - private static final WaitStrategy DEFAULT_STRATEGY = new SleepingWaitStrategy(); + private static final WaitStrategy DEFAULT_STRATEGY = PhasedBackoffWaitStrategy.withLock(1L, 30L, TimeUnit.MILLISECONDS); private static final EventHandler DISPATCH_NOTIFICATIONS = new EventHandler() { @Override public void onEvent(final DOMNotificationRouterEvent event, final long sequence, final boolean endOfBatch) throws Exception { -- 2.36.6