RFR: 8047998: -XX:InitialHeapSize is unnecessarily set to MaxHeapSize

Albert Mingkun Yang ayang at openjdk.org
Wed May 10 13:47:13 UTC 2023


On Tue, 9 May 2023 03:22:52 GMT, Guoxiong Li <gli at openjdk.org> wrote:

> Hi all,
> 
> When `MaxHeapSize` is equal to `InitialHeapSize` and `NewSize` is set in command line,
> currently, the `max_young_size/MaxNewSize` will be set to the value of `NewSize`.
> 
> Considering the document of the `NewSize` (shown below), someone may set the `NewSize` 
> to a very small value and expect the JVM to adjust the value dynamically.
> Then when the `MaxHeapSize` is equal to `InitialHeapSize` (set by user or ergonomics),
> the `MaxNewSize` is set to the value of `NewSize`, which is small unexpectedly.
> 
> 
>   product(size_t, NewSize, ScaleForWordSize(1*M),                           \
>           "Initial new generation size (in bytes)")                         \
>           constraint(NewSizeConstraintFunc,AfterErgo)                       \
> 
> 
> This patch fixes the issue by setting the `MaxNewSize` to `NewSize` only when the `NewSize` 
> is larger than the original `max_young_size/MaxNewSize`.
> 
> The title of JDK-8047998 may need to adjusted.
> 
> Thanks for the review.
> 
> Best Regards,
> -- Guoxiong

Thank you for breaking down the problem.

It's important to note that `-XX:InitialRAMPercentage=1.5625` is also included implicitly.

I can't say I'm entirely surprised by the following:

`-XX:MaxHeapSize=256M -XX:NewSize=1M -XX:MaxNewSize=80M` + `-XX:InitialRAMPercentage=1.5625` on a large RAM system leads to a constant young-size.

(Of course, one could argue that the default value of `InitialRAMPercentage` is surprising. Would `0` be any better? After all, its counterpart, `InitialHeapSize`, has `0` as the default value.)

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

PR Comment: https://git.openjdk.org/jdk/pull/13876#issuecomment-1542242310


More information about the hotspot-gc-dev mailing list