RFR: 8364638: Refactor and make accumulated GC CPU time code generic [v10]

Albert Mingkun Yang ayang at openjdk.org
Tue Aug 19 15:03:42 UTC 2025


On Tue, 19 Aug 2025 14:27:59 GMT, Jonas Norlinder <duke at openjdk.org> wrote:

> now we finally have a specific method that is called for GC activites...

Then, it should be in `Universe::before_exit`, not inside heap.

>> src/hotspot/share/services/cpuTimeUsage.hpp line 47:
>> 
>>> 45:     static jlong gc_threads();
>>> 46:     static jlong vm_thread();
>>> 47:     static jlong stringdedup();
>> 
>> I feel the API surface contains some redundancy.
>> 
>> For example, the GC-part API design exposes two ways to query and they are essentially the same -- for the sake of simplicity, I'd suggest keeping only one.
>> 
>> The calculation of `total` should be done by users of this API, I believe, when/if total is desirable.
>
> 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.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26621#discussion_r2285544932
PR Review Comment: https://git.openjdk.org/jdk/pull/26621#discussion_r2285551132


More information about the hotspot-dev mailing list