Skip to content

Commit 76ee549

Browse files
committed
8292329: Enable CDS shared heap for zero builds
Reviewed-by: shade, erikj, ihse
1 parent 14623c6 commit 76ee549

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

make/Images.gmk

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ $(eval $(call SetupExecute, jlink_jre, \
114114

115115
JLINK_JRE_TARGETS := $(jlink_jre)
116116

117+
# Optimize CDS shared heap for small heap sizes, which are typically used
118+
# for small cloud-based apps that have the most critical start-up requirement.
119+
# The trade-off is that when larger heap sizes are used, the shared heap
120+
# may need to be relocated at runtime.
121+
CDS_DUMP_FLAGS = -Xmx128M -Xms128M
122+
117123
# Helper function for creating the CDS archives for the JDK and JRE
118124
#
119125
# Param1 - VM variant (e.g., server, client, zero, ...)
@@ -122,6 +128,9 @@ define CreateCDSArchive
122128
$1_$2_DUMP_EXTRA_ARG := $(if $(filter _nocoops, $2),-XX:-UseCompressedOops,)
123129
$1_$2_DUMP_TYPE := $(if $(filter _nocoops, $2),-NOCOOPS,)
124130

131+
# Only G1 supports dumping the shared heap, so explicitly use G1 if the JVM supports it.
132+
$1_$2_CDS_DUMP_FLAGS := $(CDS_DUMP_FLAGS) $(if $(filter g1gc, $(JVM_FEATURES_$1)),-XX:+UseG1GC)
133+
125134
ifeq ($(OPENJDK_TARGET_OS), windows)
126135
$1_$2_CDS_ARCHIVE := bin/$1/classes$2.jsa
127136
else
@@ -130,24 +139,26 @@ define CreateCDSArchive
130139

131140
$$(eval $$(call SetupExecute, $1_$2_gen_cds_archive_jdk, \
132141
WARN := Creating CDS$$($1_$2_DUMP_TYPE) archive for jdk image for $1, \
142+
INFO := Using CDS flags for $1: $$($1_$2_CDS_DUMP_FLAGS), \
133143
DEPS := $$(jlink_jdk), \
134144
OUTPUT_FILE := $$(JDK_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE), \
135145
SUPPORT_DIR := $$(SUPPORT_OUTPUTDIR)/images/jdk, \
136146
COMMAND := $$(FIXPATH) $$(JDK_IMAGE_DIR)/bin/java -Xshare:dump \
137147
-XX:SharedArchiveFile=$$(JDK_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE) \
138-
-$1 $$($1_$2_DUMP_EXTRA_ARG) -Xmx128M -Xms128M $$(LOG_INFO), \
148+
-$1 $$($1_$2_DUMP_EXTRA_ARG) $$($1_$2_CDS_DUMP_FLAGS) $$(LOG_INFO), \
139149
))
140150

141151
JDK_TARGETS += $$($1_$2_gen_cds_archive_jdk)
142152

143153
$$(eval $$(call SetupExecute, $1_$2_gen_cds_archive_jre, \
144154
WARN := Creating CDS$$($1_$2_DUMP_TYPE) archive for jre image for $1, \
155+
INFO := Using CDS flags for $1: $$($1_$2_CDS_DUMP_FLAGS), \
145156
DEPS := $$(jlink_jre), \
146157
OUTPUT_FILE := $$(JRE_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE), \
147158
SUPPORT_DIR := $$(SUPPORT_OUTPUTDIR)/images/jre, \
148159
COMMAND := $$(FIXPATH) $$(JRE_IMAGE_DIR)/bin/java -Xshare:dump \
149160
-XX:SharedArchiveFile=$$(JRE_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE) \
150-
-$1 $$($1_$2_DUMP_EXTRA_ARG) -Xmx128M -Xms128M $$(LOG_INFO), \
161+
-$1 $$($1_$2_DUMP_EXTRA_ARG) $$($1_$2_CDS_DUMP_FLAGS) $$(LOG_INFO), \
151162
))
152163

153164
JRE_TARGETS += $$($1_$2_gen_cds_archive_jre)

0 commit comments

Comments
 (0)