RFR: 8332516: Serial: Refactor how promoted bytes are sampled

Albert Mingkun Yang ayang at openjdk.org
Wed May 29 09:37:09 UTC 2024


On Wed, 29 May 2024 08:38:48 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Simple heuristic update around how promoted-bytes are tracked. The real change is in `TenuredGeneration::update_promote_stats`, which uses `used-old-gen` before/after gc to derived promoted-bytes.
>> 
>> The metric is imprecise in the cases of promotion-failure, because those should be rare. Also, after full-gc, used-old-gen an be decreased; in this case, we'd set promoted bytes as the min value (zero), the best-effort estimate.
>
> src/hotspot/share/gc/serial/tenuredGeneration.cpp line 398:
> 
>> 396:     promoted_in_bytes = used_after_gc - _used_at_prologue;
>> 397:   } else {
>> 398:     promoted_in_bytes = 0;
> 
> Question about this new code vs. the old code:
> 
> So the changed code updates promotion statistics in old gen also during full gc now. The amount of "promotion" is the difference of used in old gen after and before.
> 
> I am not sure this is a good idea as the full gc also reduces the amount of existing old gen live objects. Using `0` in that case (if the full gc collects more than the implicit collection of the young gen during full collection) also seems dodgy at best.
> 
> If my reading of the code is correct and there isn't a way to correctly measure the amount of live objects in young gen during full gc I would prefer to just not update the promotion counter during full gc.
> 
> Also consider "extra" full gcs like System.gc() calls and other causes for full gc that can happen at any time - they only seem to add noise to the promoted bytes sampling.

The new logic updates promoted-bytes metric on every gc, keeping it up to date at best effort. Not updating it can result into using outdated info in deciding whether to young-gc or full-gc. The bm in https://bugs.openjdk.org/browse/JDK-8320165 shows that one can struck in full-gc forever due to this outdated metric.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19306#discussion_r1618563132


More information about the hotspot-gc-dev mailing list