From: Robert Varga Date: Mon, 30 Mar 2015 13:59:54 +0000 (+0200) Subject: Tune NotificationRouter wait strategy X-Git-Tag: release/lithium~327^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=f4595138eb29ec95958d9d55b95cc716b2fd692e;hp=a681e6bec3bbd7b536302ee9e083ae04b7f5ebdd;p=controller.git 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 --- 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 {