Netty multi-threading: do not hardcode number of threads 18/47818/1
authorLorand Jakab <lojakab@cisco.com>
Wed, 2 Nov 2016 06:38:49 +0000 (08:38 +0200)
committerLorand Jakab <lojakab@cisco.com>
Wed, 2 Nov 2016 06:38:49 +0000 (08:38 +0200)
Make the number of threads dependent on available cores. See comment in
source file for reasoning.

Change-Id: I7a1393f3879ef74ec6c5bcc756bd997a9e1bb112
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java

index d9a5e9f7f6a8751bfd0051e0b3033fd7f585af4f..dde1c45463434bc09a9e28b5491fcc5e3165a985 100644 (file)
@@ -95,7 +95,10 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
         this.clusterSingletonService = clusterSingletonService;
         this.clusterSingletonService.registerClusterSingletonService(this);
         if (Epoll.isAvailable()) {
-            numChannels = 5;
+            // When lispflowmapping is under heavy load, there are usually two threads nearing 100% CPU core
+            // utilization. In order to have some headroom, we reserve 3 cores for "other" tasks, and allow the
+            // rest to be used for southbound packet processing, which is the most CPU intensive work done in lfm
+            numChannels = Math.max(1, Runtime.getRuntime().availableProcessors() - 3);
         }
         channel = new Channel[numChannels];
     }