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

Stefan Karlsson stefank at openjdk.java.net
Wed Dec 9 07:59:37 UTC 2020


On Tue, 8 Dec 2020 13:41:56 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.

The functionality seems fine. However, the naming of things are very misleading. Arguments::limit_by_allocatable_memory has no indication that this can only be used to limit the heap memory. The non-ZGC GCs use MaxVirtMemFraction, which doesn't sound like something that has to do with the heap size. But, if you read the description of that flag it's apparent that it's about the max heap size. The added ZGC implementation also highly depend on the fact that max_virtual_memory_fraction() means the "max fraction of virtual memory that can be used by the heap". I think it would be good to name max_virtual_memory_fraction to something that indicates this. Maybe max_heap_to_virtual_memory_fraction() (maybe there's a more succinct name, that still covers what it does?) And limit_by_allocatable_memory should also be changed, before anyone starts to use it as generic function that can be used by the rest of the JVM.

If you agree maybe update the names in this PR, or create a separate RFE?

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

Marked as reviewed by stefank (Reviewer).

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


More information about the hotspot-dev mailing list