The microbenchmarks build generates a considerable amount of (generated) 
sources using an annotation processor. This, by itself, is not a problem. But, 
it generates them into the class output, and after the microbenchmarks build 
has been updated to be (somewhat) incremental, the class output has been added 
to the classpath(*):
https://github.com/openjdk/jdk/commit/b704bfa205bbd8c56f128ce5d727d40c8a3ec613

Then when the AP attempts to generate a new file (for a class name), javac will 
look for same-named classes on the classpath, and may load the source code 
generated by a previous rounds of builds, in case of an incremental build. And 
since the AP generates the considerable amount of these files, this leads to 
loading a considerable amounts of source code, eventually leading to memory 
problems ([JDK-8345302](https://bugs.openjdk.org/browse/JDK-8345302)).

The proposal herein is to split the (generated) source output from the class 
output. This considerably reduces the amount of memory javac uses, and 
generally seems like a good approach for the build.

(*) adding the class output to the classpath is usually needed when 
incrementally compiling code in the unnamed module, to ensure that if e.g. only 
one source file is being compiled, it can refer to other, already produced, 
classes. As a side note, this does not need to be done in named-module 
compilation modes, as javac automatically reads the class output when compiling 
the named modules. But it is not easily possible to enhance javac to do that 
for unnamed module, due to compatibility concerns.

-------------

Commit messages:
 - 8345942: Separate source output from class output when building 
microbenchmarks

Changes: https://git.openjdk.org/jdk/pull/22731/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22731&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8345942
  Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/22731.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22731/head:pull/22731

PR: https://git.openjdk.org/jdk/pull/22731

Reply via email to