On Fri, 1 Dec 2023 14:42:22 GMT, Albert Mingkun Yang <ay...@openjdk.org> wrote:
>> I would say it depends on the use-case and here when switching to use static >> functions to use the instance it felt more like an all-static class. I agree >> that it would be nice to avoid the additional memory usage if `UsePerfData` >> is `false` so I'm ok with keeping the instance if we add that. > >> It is easier to control the initialization order and timing of an on-heap >> singleton object than statics. > > It's generally true, but the init of CPUTimeCounters is not sensitive to > ordering. > >> This could save some memory when UsePerfData is false. > > True, but the mem savings will be marginal at most, `PerfCounter* > _cpu_time_counters[static_cast<int>(CPUTimeGroups::CPUTimeType::COUNT)];` > will be 8 * ~12 = ~96 bytes (including future cpu-time-type enums). > > (I don't have a strong preference here; however, I'd like to make the pros > and cons explicit.) Added the check in the initializer ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15082#discussion_r1412749097