diff options
author | buchgr <buchgr@google.com> | 2018-07-23 05:43:41 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-23 05:45:32 -0700 |
commit | 3842bd39e10612c7eef36c6048407e81bcd0a8fb (patch) | |
tree | 66cbfffffd37f531ecae5fa776bb3adc651ede94 /tools | |
parent | ebdf218ec60218aadbfcce4309a797a7166040e8 (diff) |
jdk: use parallel old gc and disable compact strings
When switching to JDK9 we regressed on java build performance by about ~30%.
We found that when using parallel gc instead of G1 and disabling compact
strings for JavaBuilder, the java build performance is "only" 10% slower.
We additionally found JDK9 to have a significantly higher startup time.
This impacts the performance of tools like javac and tubine and we
believe that this accounts for most of the remaining overhead that can't
be explained by disabling G1 and compact strings.
java8 -version: 80ms
java9 -version: 140ms
java10 -version: 110ms
Additionally, we found that the number of modules shipped with the JDK
have a direct effect on the startup time. When building Java 10 with only
the 9 modules required by Bazel we find that the startup time reduces to
80ms (from 110ms) which is on par with Java 8.
We thus expect the regression to be fixed by a future migration to Java 10,
which should be done in one of the next Bazel releases.
== Some benchmark results ==
https://github.com/google/protobuf
$ bazel build :protobuf_java
Bazel 0.15.2: 4.2s
Bazel 0.16.0-rc2: 5.2s
This Change: 4.2s
https://github.com/jin/android-projects/tree/master/java_only
$ bazel build :module0
Bazel 0.15.2: 8.2s
Bazel 0.16.0-rc2: 11.5s
This Change: 9.1s
RELNOTES: None
PiperOrigin-RevId: 205647957
Diffstat (limited to 'tools')
-rw-r--r-- | tools/jdk/default_java_toolchain.bzl | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/jdk/default_java_toolchain.bzl b/tools/jdk/default_java_toolchain.bzl index f4dc03577c..c518d026b3 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", |