RFR: JDK-8292072: NMT: repurpose Tracking overhead counter as global malloc counter
Ioi Lam
iklam at openjdk.org
Thu Aug 11 23:08:44 UTC 2022
On Tue, 9 Aug 2022 06:13:13 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> I need a fast counter for global mallocs for [JDK-8291878](https://bugs.openjdk.org/browse/JDK-8291878). NMT does not keep a global counter, just category-specific counters. At the moment, `MallocMemorySummary::total()` iterates all these counters and adds them up, which is quite costly.
>
> This patch makes `MallocMemorySummary::total()` fast by introducing a global malloc counter. However, we don't add a new counter, we just repurpose the tracking overhead counter.
>
> The tracking overhead counter gets updated on every malloc and counts number and size of all malloc headers. But malloc headers have always the same size. This patch uses the former overhead counter to count number and size of all mallocs. So now we have a global malloc counter, at no additional cost, and the overhead gets calculated from the number of total mallocs * constant header size.
Marked as reviewed by iklam (Reviewer).
This looks like a good simplification. I can confirmed that the old counter was always used with a constant size, so I think your fix is correct.
record_new_malloc_header(sizeof(MallocHeader))
Have you done any testing to confirm that the old and new code reports the same overhead numbers. I see that you've moved the accounting code around so I am not sure if all the accountings are still being done at the exact same places.
Also, if possible, a new gtest would be useful.
-------------
PR: https://git.openjdk.org/jdk/pull/9804
More information about the hotspot-runtime-dev
mailing list