RFR: JDK-8293114: JVM should trim the native heap [v7]
Thomas Stuefe
stuefe at openjdk.org
Mon Jul 10 12:31:21 UTC 2023
On Mon, 10 Jul 2023 11:06:23 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> Thomas Stuefe has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Add test with 1ms trim interval
>> - No need for atomics
>
> src/hotspot/share/runtime/trimNativeHeap.cpp line 106:
>
>> 104: ml.wait(wait_ms);
>> 105: } else if (at_or_nearing_safepoint()) {
>> 106: ml.wait(safepoint_poll_ms);
>
> OK, so here is a little problem. Suppose I want to run trims very often, like every 10ms. This loop would stall for 250ms when safepoint is detected, which throws off this guarantee. Can we instead go and sleep for `TrimNativeHeapInterval`? AFAICs, this plays nicely with heuristic guidance (short intervals -> more interference), and it would best-effort stall for twice the interval when safepoint interjects.
But then we have a problem for larger trim intervals. Loosing one or multiple trim attempts because a safepoint happened to happen hurts if the interval is e.g. 5 minutes.
We could either wait for `MIN2(TrimNativeHeapInterval, safepoint_poll_ms)`.
Or, at the cost of one Mutex grab per safepoint, I could do a `notify_all()` at the end of a safepoint.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14781#discussion_r1258176657
More information about the serviceability-dev
mailing list