RFR: JDK-8315478: GenShen: Tolerate round-off errors in preselected promotion budget

Y. Srinivas Ramakrishna ysr at openjdk.org
Sat Sep 2 01:02:12 UTC 2023


On Sat, 2 Sep 2023 00:46:22 GMT, Y. Srinivas Ramakrishna <ysr at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp line 409:
>> 
>>> 407: 
>>> 408:   assert(old_available >= old_consumed, "Cannot consume (" SIZE_FORMAT ") more than is available (" SIZE_FORMAT ")",
>>> 409:          old_consumed, old_available);
>> 
>> So you are just adding debugging code to catch the issue more easily? (as well as the change further below)
>> 
>> I don't see any change in the control flow or the state here.
>> 
>> Is the intention to add this change and the one below to aid debugging of a very difficult to reproduce problem?
>
> ah, never mind, I see that you are adjusting some values there, which I missed in a first reading of the code.
> 
> I don't understand this logic well enough to review this change, so please go ahead an land this with the review you have from William.

old_consumed = old_evacuated_committed + old_available - old_evacuated_committed
                             = old_available

So effectively this is saying if `old_available < old_consumed`, make `old_available = old_consumed` so the subsequent assertion is satisfied. You are asserting that this can only happen if the difference is because of round-off errors.

I do have a question about this, though. Can we avoid the round-off errors in the arithmetic entirely, by doing rounding in the "safe direction" (e.g. rounding down or up) at each step where rounding is needed, rather than relying on catching the condition and adjusting the values to re-establish the invariants?

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

PR Review Comment: https://git.openjdk.org/shenandoah/pull/317#discussion_r1313672240


More information about the shenandoah-dev mailing list