RFR: JDK-8292072: NMT: repurpose Tracking overhead counter as global malloc counter [v2]
Christoph Langer
clanger at openjdk.org
Sat Aug 13 16:29:11 UTC 2022
On Fri, 12 Aug 2022 07:27:07 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.
>>
>> ---
>>
>> Tests done:
>>
>> - GHAs (which execute NMT jtreg + gtests tests in all modes)
>> - manual test (checking that tracking overhead numbers are the same as before)
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>
> Add NMT gtest to test malloc tracker totals
Looks good from what I can tell. I've added two remarks - not sure whether they are meaningful.
src/hotspot/share/services/mallocTracker.hpp line 159:
> 157: // Total malloc invocation count
> 158: size_t total_count() const {
> 159: return _all_mallocs.count();
Is this correct style to implement the method in the header? Shouldn't it maybe be `inline`?
src/hotspot/share/services/mallocTracker.hpp line 164:
> 162: // Total malloc'd memory amount
> 163: size_t total() const {
> 164: return _all_mallocs.size() + malloc_overhead() + total_arena();
Same here: Is this correct style to implement the method in the header? Shouldn't it maybe be `inline`?
-------------
Marked as reviewed by clanger (Reviewer).
PR: https://git.openjdk.org/jdk/pull/9804
More information about the hotspot-runtime-dev
mailing list