RFR: 8332514: Allow class space size to be larger than 3GB
Thomas Stuefe
stuefe at openjdk.org
Sun May 26 05:17:02 UTC 2024
On Sat, 25 May 2024 06:54:12 GMT, Ioi Lam <iklam 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.
I wanted to have some form of safety against, e.g., malicious attacks that modify archive size. This seemed to be the simplest way. I can exchange 1G for any other reasonable number, but think there should be a limit.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19347#discussion_r1615024781
More information about the hotspot-runtime-dev
mailing list