From 8970c1d7442f0f4c1542d418df3b609aa572faf7 Mon Sep 17 00:00:00 2001 From: Jacek Date: Wed, 11 Aug 2021 09:57:45 +0200 Subject: [PATCH] SONAR-15244 Use G1GC for Elasticsearch (cherry picked from commit 7b8885e93c0e9c48d0d4c4b0e4651d9afc3e916b) --- .../org/sonar/application/command/EsJvmOptions.java | 4 +--- .../application/command/CommandFactoryImplTest.java | 9 ++++++--- .../sonar/application/command/EsJvmOptionsTest.java | 10 +++------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java index 0063e9c32e6..6f3f6b4432b 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java +++ b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java @@ -55,9 +55,7 @@ public class EsJvmOptions extends JvmOptions { private static void fromJvmDotOptionsFile(File tmpDir, Map res) { // GC configuration - res.put("-XX:+UseConcMarkSweepGC", ""); - res.put("-XX:CMSInitiatingOccupancyFraction=", "75"); - res.put("-XX:+UseCMSInitiatingOccupancyOnly", ""); + res.put("-XX:+UseG1GC", ""); // (by default ES 6.6.1 uses variable ${ES_TMPDIR} which is replaced by start scripts. Since we start JAR file // directly on windows, we specify absolute file as URL (to support space in path) instead diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java index e8318bc1b5f..7fe5d39a40d 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java @@ -135,7 +135,8 @@ public class CommandFactoryImplTest { assertThat(esConfig.getHttpPort()).isEqualTo(9001); assertThat(esConfig.getEsJvmOptions().getAll()) // enforced values - .contains("-XX:+UseConcMarkSweepGC", "-Dfile.encoding=UTF-8") + .contains("-XX:+UseG1GC") + .contains("-Dfile.encoding=UTF-8") // default settings .contains("-Xms512m", "-Xmx512m", "-XX:+HeapDumpOnOutOfMemoryError"); assertThat(esConfig.getEsYmlSettings()).isNotNull(); @@ -170,7 +171,8 @@ public class CommandFactoryImplTest { assertThat(esConfig.getHttpPort()).isEqualTo(9001); assertThat(esConfig.getEsJvmOptions().getAll()) // enforced values - .contains("-XX:+UseConcMarkSweepGC", "-Dfile.encoding=UTF-8") + .contains("-XX:+UseG1GC") + .contains("-Dfile.encoding=UTF-8") // default settings .contains("-Xms512m", "-Xmx512m", "-XX:+HeapDumpOnOutOfMemoryError"); assertThat(esConfig.getEsYmlSettings()).isNotNull(); @@ -210,7 +212,8 @@ public class CommandFactoryImplTest { assertThat(esConfig.getHttpPort()).isEqualTo(1234); assertThat(esConfig.getEsJvmOptions().getAll()) // enforced values - .contains("-XX:+UseConcMarkSweepGC", "-Dfile.encoding=UTF-8") + .contains("-XX:+UseG1GC") + .contains("-Dfile.encoding=UTF-8") .contains("-Djava.io.tmpdir=" + tempDir.getAbsolutePath()) // user settings .contains("-Xms10G", "-Xmx10G") diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java index 693d173213d..47d900b8277 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java @@ -49,10 +49,8 @@ public class EsJvmOptionsTest { EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir); assertThat(underTest.getAll()) - .containsExactlyInAnyOrder( - "-XX:+UseConcMarkSweepGC", - "-XX:CMSInitiatingOccupancyFraction=75", - "-XX:+UseCMSInitiatingOccupancyOnly", + .containsExactly( + "-XX:+UseG1GC", "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath(), "-XX:ErrorFile=../logs/es_hs_err_pid%p.log", "-Des.networkaddress.cache.ttl=60", @@ -134,9 +132,7 @@ public class EsJvmOptionsTest { "\n" + "# DO NOT EDIT THIS FILE\n" + "\n" + - "-XX:+UseConcMarkSweepGC\n" + - "-XX:CMSInitiatingOccupancyFraction=75\n" + - "-XX:+UseCMSInitiatingOccupancyOnly\n" + + "-XX:+UseG1GC\n" + "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath() + "\n" + "-XX:ErrorFile=../logs/es_hs_err_pid%p.log\n" + "-Des.networkaddress.cache.ttl=60\n" + -- 2.39.5