RFR: 8332514: Allow class space size to be larger than 3GB

Ioi Lam iklam at openjdk.org
Sat May 25 07:08:02 UTC 2024


On Wed, 22 May 2024 12:05:28 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Class space size is capped at 3GB. Technically, the Klass encoding range is 4GB.
> 
> We cap class space at 3GB to leave breathing room for CDS. However, CDS needs a lot less, so we waste address space. In addition, class space is unnecessarily capped at 3GB even if we run without CDS, which is unnecessary.
> 
> What we should do instead:
> - if CDS is off, use the full 4GB
> - if CDS is on, use as much memory as we can after accommodating the archive
> 
> This patch implements that new behavior. 
> 
> Now, we can have 4GB class space without CDS; with CDS, a bit less (depends on the CDS archive size; by default, on MacOS, we reach about 3.98GB).

src/hotspot/share/cds/metaspaceShared.cpp line 1269:

> 1267:   size_t archive_end_offset  = (dynamic_mapinfo == nullptr) ? static_mapinfo->mapping_end_offset() : dynamic_mapinfo->mapping_end_offset();
> 1268:   size_t archive_space_size = align_up(archive_end_offset, archive_space_alignment);
> 1269:   guarantee(archive_space_size < G, "weirdly large archive (" SIZE_FORMAT ")", archive_space_size);

Why is this needed? We don't have a corresponding check when creating the archive.

test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java line 28:

> 26:  * @bug 8022865
> 27:  * @summary Tests for the -XX:CompressedClassSpaceSize command line option
> 28:  * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true & vm.cds

All test cases unrelated to CDS will also be disabled if the JVM is not configured with CDS.

I think it's better to move the new test cases to a new file.

test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java line 76:

> 74:         // With CDS, class space should fill whatever the CDS archive leaves us (modulo alignment)
> 75:         pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + max_class_space_size,
> 76:                 "-Xshare:on", "-Xlog:metaspace*", "-version");

The `vm.cds` property indicates whether the JDK was built with INCLUDE_CDS. It doesn't guarantee that a CDS archive is included in the JDK -- a JDK can be configured with `--disable-cds-archive`.

It's better to generate a dummy CDS archive and use it explicitly in the test.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19347#discussion_r1614396100
PR Review Comment: https://git.openjdk.org/jdk/pull/19347#discussion_r1614402398
PR Review Comment: https://git.openjdk.org/jdk/pull/19347#discussion_r1614401907


More information about the hotspot-runtime-dev mailing list