RFR: 8364638: Refactor and make accumulated GC CPU time code generic [v10]
Jonas Norlinder
duke at openjdk.org
Tue Aug 19 16:03:42 UTC 2025
On Tue, 19 Aug 2025 15:00:15 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>> The motivation for `total()` is that this is probably what most users want, but in case anyone want a sub-component I also expose each one of them. It also serves as documentation as what we currently consider to be "total", so I would prefer keeping it.
>>
>> If you look at e.g. `WeakProcessor::CountingClosure` the following is defined
>>
>> size_t dead() const { return _old_dead + _new_dead; }
>> size_t new_dead() const { return _new_dead; }
>> size_t total() const { return dead() + _live; }
>>
>>
>> so having such convenience method in hotspot is not unprecedented and I would prefer keeping it.
>>
>> `statistics()` is a less important convenience method that can be removed.
>
> I think the smallest API would be `statisics()`, which returns all sub-components, and consumers of this API can calculate other derived metrics. YMMV.
I would remove `CPUTimeUsage::GC::statistics()` as I would prefer having coherent types between classes in the namespace and since using structs over of classes defeats some of the utility of putting everything into a namespace.
For instance, it makes little sense to define a struct for `Runtime` which only include one component currently and it would be less than ideal to return `jlong` for some classes and custom structs for others if we only have to pick one of these approaches.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26621#discussion_r2285707652
More information about the hotspot-dev
mailing list