BUG-4689: Advertising performance fix 33/31033/2
authorMilos Fabian <milfabia@cisco.com>
Wed, 9 Dec 2015 00:30:56 +0000 (01:30 +0100)
committerMilos Fabian <milfabia@cisco.com>
Fri, 11 Dec 2015 13:05:27 +0000 (14:05 +0100)
The TCP channel become unwritable too fast and too often, hence
use high & low write watermark option for channel.

Change-Id: Icd52f164153dde94cd7c61a0c38f805a5c0593cf
Signed-off-by: Milos Fabian <milfabia@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java

index 4034eec7a381dc516125d4209e4865f25373bae1..3fcb966ed3a7153a45c643eba4c1fd5199411f17 100644 (file)
@@ -49,6 +49,9 @@ import org.slf4j.LoggerFactory;
 public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(BGPDispatcherImpl.class);
     private static final int SOCKET_BACKLOG_SIZE = 128;
+    private static final int HIGH_WATER_MARK = 256 * 1024;
+    private static final int LOW_WATER_MARK = 128 * 1024;
+
     private final MD5ServerChannelFactory<?> serverChannelFactory;
     private final MD5ChannelFactory<?> channelFactory;
     private final BGPHandlerFactory handlerFactory;
@@ -99,6 +102,8 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         // Make sure we are doing round-robin processing
         bootstrap.option(ChannelOption.MAX_MESSAGES_PER_READ, 1);
         bootstrap.option(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
+        bootstrap.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, HIGH_WATER_MARK);
+        bootstrap.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, LOW_WATER_MARK);
 
         if (bootstrap.group() == null) {
             bootstrap.group(this.workerGroup);
@@ -139,6 +144,8 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         serverBootstrap.childHandler(BGPChannel.createChannelInitializer(initializer, new DefaultPromise(BGPDispatcherImpl.this.executor)));
         serverBootstrap.option(ChannelOption.SO_BACKLOG, Integer.valueOf(SOCKET_BACKLOG_SIZE));
         serverBootstrap.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
+        serverBootstrap.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, HIGH_WATER_MARK);
+        serverBootstrap.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, LOW_WATER_MARK);
         if (this.keys.isPresent()) {
             if (this.serverChannelFactory == null) {
                 throw new UnsupportedOperationException("No key access instance available, cannot use key mapping");