RFR: 8047998: -XX:MaxNewSize is unnecessarily set to NewSize if NewSize is too low

Albert Mingkun Yang ayang at openjdk.org
Fri May 26 12:09:58 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

As far as I understand it, there are potentially two issues here:

1. `InitialRAMPercentage` and `InitialHeapSize` control the same attribute but they have diff default value.

2. `MaxNewSize` can be silently ignored in certain cases. For example:


java -XX:+UseSerialGC -XX:InitialHeapSize=256m -XX:MaxHeapSize=256M -XX:NewSize=8M -XX:MaxNewSize=80M '-Xlog:gc,gc+heap=trace' --version


Partial output: `Initial young 8388608  Maximum young 8388608` meaning that `MaxNewSize=80M` is silently ignored/discarded/overwritten, which can be surprising, especially when `-XX:InitialHeapSize=256m` (or even larger value) is derived from the default and implicit `InitialRAMPercentage`.

Regardless of issue 1, maybe emitting a warning/error would be less surprising in the case of issue 2. (Your concern is mostly issue 2, right?)

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

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


More information about the hotspot-gc-dev mailing list