On Tue, 23 Aug 2022 15:56:35 GMT, Ioi Lam <ik...@openjdk.org> wrote:

> ZERO uses UseSerialGC by default. When we dump the default CDS archive during 
> the build process, it fails to dump the shared heap (which requires G1GC).
> 
> The fix is to force -XX:+UseG1GC when dumping the default CDS archive during 
> the build process.
> 
> Speed up:
> 
> (Before)
> $ perf stat -r 40 ./images/jdk/bin/java -version
> 0.018080 +- 0.000388 seconds time elapsed ( +- 2.15% )
> 
> (After)
> $ perf stat -r 40 ./images/jdk/bin/java -version
> 0.011986 +- 0.000205 seconds time elapsed ( +- 1.71% )

Honestly, after [https://bugs.openjdk.org/browse/JDK-8256497](JDK-8256497), 
Zero could just use G1 by default and avoid this mess. I'll look into it later. 
This PR is still useful on its own meanwhile, and we can drop the mention of 
Zero that would be stale.

make/Images.gmk line 132:

> 130: 
> 131:   # Only G1 supports dumping the shared heap, so explicitly use G1
> 132:   # it if the JVM supports it. (Note: the default GC with zero is 
> SerialGC)

Suggestion:

  # Only G1 supports dumping the shared heap, so explicitly use G1 if the JVM 
supports it.

make/Images.gmk line 133:

> 131:   # Only G1 supports dumping the shared heap, so explicitly use G1
> 132:   # it if the JVM supports it. (Note: the default GC with zero is 
> SerialGC)
> 133:   $1_$2_CDS_DUMP_FLAGS := $(CDS_DUMP_FLAGS) $(if $(filter g1gc, 
> $(JVM_FEATURES_$1)),-XX:+UseG1GC)

I think it should be e.g. (untested):

Suggestion:

  $1_$2_CDS_DUMP_FLAGS := $(CDS_DUMP_FLAGS)
  ifeq ($(call check-jvm-feature, g1gc), true)
     $1_$2_CDS_DUMP_FLAGS += -XX:+UseG1GC
  endif

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

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

Reply via email to