RFR: 8257901: ZGC: Take virtual memory usage into account when sizing heap [v2]

Thomas Schatzl tschatzl at openjdk.java.net
Wed Dec 9 11:32:36 UTC 2020


On Wed, 9 Dec 2020 09:41:49 GMT, Per Liden <pliden at openjdk.org> wrote:

>> MaxVirtMemFraction limits the amount of address space the GC should use for the heap. This is used by the heuristics in Arguments::set_heap_size() to select an appropriate default max heap size. However, that heuristic can select a max heap size that will not fit with ZGC, since ZGC uses additional address space (for multi-mapping and the virtual-to-physical ratio). As a result, if the address space is limited, and -Xmx is not specified, then ZGC might refuse to start with the error:
>> 
>> "Failed to reserve enough address space for Java heap"
>> 
>> I propose we abstract MaxVirtMemFraction to make it configurable for each GC, so that the heuristics in Arguments::set_heap_size() will pick a default max heap size that also works for ZGC.
>> 
>> Testing: Manual testing using different ulimit -v sizes.
>
> Per Liden has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review StefanK

Changes requested by tschatzl (Reviewer).

src/hotspot/share/gc/shared/gcArguments.cpp line 178:

> 176: size_t GCArguments::heap_virtual_to_physical_ratio() {
> 177:   // Used by heap size heuristics to determine max amount
> 178:   // of address space to use for the heap.

Could this explanation moved to the hpp file? Then some IDEs will automatically pick it up. I'd expect a comments to the implementation, i.e. of the value 1 here instead of a generic explanation of what the method does.

src/hotspot/share/runtime/arguments.cpp line 1658:

> 1656: }
> 1657: 
> 1658: julong Arguments::limit_heap_by_allocatable_memory(julong limit) {

If we are already messing with the name in this change, would it be possible to change return value and parameter to `size_t`? I'm good with moving this change of the parameter types to a different issue, but as mentioned, since we are already changing stuff around here...

src/hotspot/share/runtime/arguments.hpp line 368:

> 366:   // limits the given memory size by the maximum amount of memory this process is
> 367:   // currently allowed to allocate or reserve.
> 368:   static julong limit_heap_by_allocatable_memory(julong size);

Please clarify the documentation of this method also according to the results of this discussion.

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

PR: https://git.openjdk.java.net/jdk/pull/1696


More information about the hotspot-dev mailing list