RFR: 8372543: Shenandoah: undercalculated the available size when soft max takes effect [v2]
Rui Li
duke at openjdk.org
Thu Dec 4 01:43:36 UTC 2025
> Detailed math and repro see https://bugs.openjdk.org/browse/JDK-8372543.
>
> Currently in shenandoah, when deciding whether to have gc, how we calculate available size is:
>
>
> available = (Xmx * (100 - ShenandoahEvacReserve) / 100) - used
> soft_tail = Xmx - soft_max
> if (available - soft_tail < ShenandoahMinFreeThreshold * soft_max) // trigger gc
>
>
> The if condition `available - soft_tail` will be reduced to: `-(ShenandoahEvacReserve/100) * Xmx - used + soft_max`, which means when soft max is the same, the larger Xmx is, the less free size the app would have and the more gc it would have, which does not make sense, especially for the case where the app is mostly idle. This caused one of our internal customers experienced frequent gc with minimal workload, when soft max heap size was set way lower than Xmx.
>
>
> Suggested fix: when deciding when to trigger gc, use logic similar to below:
>
> mutator_soft_capacity = soft_max * (100 - ShenandoahEvacReserve) / 100;
> available = mutator_soft_capacity - used;
> if (available < mutator_soft_capacity) // trigger gc
> ```
>
> -------
> This change also improved gc logging:
>
> Before:
>
> [6.831s][info][gc ] Trigger: Free (52230K) is below minimum threshold (52428K)
> [6.831s][info][gc,free ] Free: 1587M, Max: 1024K regular, 1539M humongous, Frag: 2%
> external, 18% internal; Used: 352M, Mutator Free: 1940 Collector Reserve: 103M, Max: 1024K; Used: 0B
>
>
> After:
>
> [8.358s][info][gc ] Trigger: Free (Soft mutator free) (51498K) is below minimum threshold (52428K)
> [8.358s][info][gc,free ] Whole heap stats: Total free: 1509M, Total used: 401M, Max free in a single region:
> 1024K, Max humongous: 1490M; Frag stats: External: 0%, Internal: 21%; Mutator freeset stats: Partition count:
> 1911, Reserved: 1509M, Max free available in a single region: 1024K; Collector freeset stats: Partition count:
> 122, Reserved: 102M, Max free available in a single region: 1024K;
Rui Li has updated the pull request incrementally with two additional commits since the last revision:
- Rename soft_available. Change Generation soft avail impl
- log format fixes
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/28622/files
- new: https://git.openjdk.org/jdk/pull/28622/files/b23e9ff1..103ce8f8
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=28622&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=28622&range=00-01
Stats: 35 lines in 11 files changed: 2 ins; 7 del; 26 mod
Patch: https://git.openjdk.org/jdk/pull/28622.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28622/head:pull/28622
PR: https://git.openjdk.org/jdk/pull/28622
More information about the shenandoah-dev
mailing list