From 9d562da5c81eafbe80ce75f80e1f13b5f15ec9d4 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Thu, 22 Aug 2019 15:47:33 -0500 Subject: [PATCH 1/2] Set netty system properties in BuildPlugin Currently in production instances of Elasticsearch we set a couple of system properties by default. We currently do not apply all of these system properties in tests. This commit applies these properties in the tests. Additionally it enables the unpooled allocator about 1/4 of the time, the pooled allocator with direct buffer pooling about 1/4 of the time, and the pooled allocator without direct buffer pooling about 1/2 of the time. --- .../org/elasticsearch/gradle/BuildPlugin.groovy | 16 ++++++++++++++++ modules/transport-netty4/build.gradle | 6 ------ .../java/org/elasticsearch/test/ESTestCase.java | 3 --- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 75adcbea2f166..f61c35d1590f3 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -884,6 +884,22 @@ class BuildPlugin implements Plugin { // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0 test.systemProperty 'es.transport.cname_in_publish_address', 'true' + // Set netty system properties + test.systemProperty('io.netty.noUnsafe', 'true') + test.systemProperty('io.netty.noKeySetOptimization', 'true') + test.systemProperty('io.netty.recycler.maxCapacityPerThread', '0') + def seed = Long.parseUnsignedLong(((String) project.property('testSeed')).tokenize(':').get(0), 16) + if (seed % 4 == 0) { + // Occasionally use the unpooled allocator as we ergonomically choose it on small heaps + test.systemProperty('io.netty.allocator.type', 'unpooled') + } else { + test.systemProperty('io.netty.allocator.type', 'pooled') + if (seed % 2 != 0) { + // Disable direct buffer pooling most of the time as it is disabled by default in Elasticsearch + test.systemProperty('io.netty.allocator.numDirectArenas', '0') + } + } + test.testLogging { TestLoggingContainer logging -> logging.showExceptions = true logging.showCauses = true diff --git a/modules/transport-netty4/build.gradle b/modules/transport-netty4/build.gradle index ff21cfa30d357..b390ab3af5829 100644 --- a/modules/transport-netty4/build.gradle +++ b/modules/transport-netty4/build.gradle @@ -51,9 +51,6 @@ test { * other if we allow them to set the number of available processors as it's set-once in Netty. */ systemProperty 'es.set.netty.runtime.available.processors', 'false' - - // Disable direct buffer pooling as it is disabled by default in Elasticsearch - systemProperty 'io.netty.allocator.numDirectArenas', '0' } integTestRunner { @@ -62,9 +59,6 @@ integTestRunner { * other if we allow them to set the number of available processors as it's set-once in Netty. */ systemProperty 'es.set.netty.runtime.available.processors', 'false' - - // Disable direct buffer pooling as it is disabled by default in Elasticsearch - systemProperty 'io.netty.allocator.numDirectArenas', '0' } thirdPartyAudit { diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index b911a963073d2..857c32426c641 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -242,9 +242,6 @@ private static void setTestSysProps() { // Enable Netty leak detection and monitor logger for logged leak errors System.setProperty("io.netty.leakDetection.level", "paranoid"); - - // Disable direct buffer pooling - System.setProperty("io.netty.allocator.numDirectArenas", "0"); } protected final Logger logger = LogManager.getLogger(getClass()); From 904d93845f101abe840047fbed50f7252db013cc Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Thu, 29 Aug 2019 09:12:47 -0600 Subject: [PATCH 2/2] Change --- .../org/elasticsearch/gradle/BuildPlugin.groovy | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index f2d409ee44a89..d6710d7828c81 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -887,21 +887,11 @@ class BuildPlugin implements Plugin { // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0 test.systemProperty 'es.transport.cname_in_publish_address', 'true' - // Set netty system properties + // Set netty system properties to the properties we configure in jvm.options test.systemProperty('io.netty.noUnsafe', 'true') test.systemProperty('io.netty.noKeySetOptimization', 'true') test.systemProperty('io.netty.recycler.maxCapacityPerThread', '0') - def seed = Long.parseUnsignedLong(((String) project.property('testSeed')).tokenize(':').get(0), 16) - if (seed % 4 == 0) { - // Occasionally use the unpooled allocator as we ergonomically choose it on small heaps - test.systemProperty('io.netty.allocator.type', 'unpooled') - } else { - test.systemProperty('io.netty.allocator.type', 'pooled') - if (seed % 2 != 0) { - // Disable direct buffer pooling most of the time as it is disabled by default in Elasticsearch - test.systemProperty('io.netty.allocator.numDirectArenas', '0') - } - } + test.systemProperty('io.netty.allocator.numDirectArenas', '0') test.testLogging { TestLoggingContainer logging -> logging.showExceptions = true