diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index 5813619b68140f..739dc20ff863f2 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -420,8 +420,12 @@ static vector GetArgumentArray( // TODO(b/109998449): only assume JDK >= 9 for embedded JDKs if (!globals->options->GetEmbeddedJavabase().empty()) { - // quiet warnings from com.google.protobuf.UnsafeUtil, + // In JDK9 we have seen a slow down when using the default G1 collector + // and thus switch back to parallel gc. + result.push_back("-XX:+UseParallelOldGC"); // see: https://github.com/google/protobuf/issues/3781 + + // quiet warnings from com.google.protobuf.UnsafeUtil, result.push_back("--add-opens=java.base/java.nio=ALL-UNNAMED"); } diff --git a/tools/jdk/default_java_toolchain.bzl b/tools/jdk/default_java_toolchain.bzl index f4dc03577c5e6b..c518d026b374d7 100644 --- a/tools/jdk/default_java_toolchain.bzl +++ b/tools/jdk/default_java_toolchain.bzl @@ -19,6 +19,10 @@ JDK8_JVM_OPTS = [ ] JDK9_JVM_OPTS = [ + # In JDK9 we have seen a ~30% slow down in JavaBuilder performance when using + # G1 collector and having compact strings enabled. + "-XX:+UseParallelOldGC", + "-XX:-CompactStrings", # Allow JavaBuilder to access internal javac APIs. "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",