Protocol framework: use pooled ByteBuf allocator 69/7769/6
authorRobert Varga <rovarga@cisco.com>
Fri, 6 Jun 2014 08:39:35 +0000 (10:39 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 30 Jun 2014 10:38:32 +0000 (12:38 +0200)
This should enhance the default performance characteristics by reusing
ByteBufs if possible. With 4.0.19, netty keeps a thread-local cache of
direct buffers, so we should see a reduction in buffer copying, if not
other effects.

Change-Id: I81fcf380f6f3b03187000dbca0dd8507975e8dd1
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java

index fef2c7196948c007705b4444a5c9445065618648..635bb1076e82aa7b0d33db9f1e2170c4abcedf0a 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.base.Preconditions;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.Channel;
+import io.netty.buffer.PooledByteBufAllocator;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelOption;
@@ -110,6 +111,7 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
             // makes no sense for LocalServer and produces warning
             b.childOption(ChannelOption.SO_KEEPALIVE, true);
         }
+        b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
         customizeBootstrap(b);
 
         if (b.group() == null) {