RFR: 8330198: Add some class loading related perf counters to measure VM startup [v3]

Calvin Cheung ccheung at openjdk.org
Fri May 24 05:24:04 UTC 2024


On Thu, 23 May 2024 22:33:09 GMT, David Holmes <dholmes at openjdk.org> wrote:

> Okay my first reaction here is "I object!". I get that Leyden wants to be able to easily compare startup costs between itself and mainline, but what is this costing mainline? Even if these counters are not active there is an impact on the code execution and I want to know that impact is negligible.

I added some perf numbers for various startup benchmarks in the bug report [comment](https://bugs.openjdk.org/browse/JDK-8330198?focusedId=14675860&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14675860).

> src/hotspot/share/classfile/classLoader.cpp line 1481:
> 
>> 1479: 
>> 1480: jlong ClassLoader::class_init_time_ms() {
>> 1481:   return (UsePerfData) ?
> 
> Or here

Please refer to my reply above.

> src/hotspot/share/oops/instanceKlass.cpp line 1219:
> 
>> 1217:     } else {
>> 1218:       // The elapsed time is so small it's not worth counting.
>> 1219:       if (UsePerfData || ProfileClassLinkage) {
> 
> You have to have UsePerfData being true for this work so you don't need the change.

Right, the `_perf_classes_inited` counter is a pre-existing counter whose creation depends on `UsePerfData`.

> src/hotspot/share/runtime/arguments.cpp line 3759:
> 
>> 3757:   if (log_is_enabled(Info, init)) {
>> 3758:      FLAG_SET_ERGO_IF_DEFAULT(ProfileClassLinkage, true);
>> 3759:   }
> 
> What if ProfileClassLinkage is set true on the command-line without -Xlog:init? That doesn't seem to make sense to me. So I'm not clear why it is a settable diagnostic flag.

If only `ProfileClassLinkage` is set to true without `-Xlog:init`, the user will not see any counters output.
In `java.cpp`:

160 void log_vm_init_stats() {
161   LogStreamHandle(Info, init) log;
162   if (log.is_enabled()) {
163     ClassLoader::print_counters();
164   }
165 }


In the future, there will be other sets of counters controlled by other diagnostic flags.

> src/hotspot/share/runtime/perfData.hpp line 834:
> 
>> 832:   public:
>> 833:     inline PerfTraceTime(PerfLongCounter* timerp) : _timerp(timerp) {
>> 834:       if (!UsePerfData || timerp == nullptr) return;
> 
> Okay so this is needed because the existence of some counters is gated on the ProfileClassLinkage flag.
> 
> Style nit: use a { } block please.

Will fix.

> src/hotspot/share/runtime/perfData.hpp line 838:
> 
>> 836:     }
>> 837: 
>> 838:     const char* name() const { return _timerp->name(); }
> 
> Do you need a null check here?

Will add a null check.

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

PR Comment: https://git.openjdk.org/jdk/pull/18790#issuecomment-2128547516
PR Review Comment: https://git.openjdk.org/jdk/pull/18790#discussion_r1612774777
PR Review Comment: https://git.openjdk.org/jdk/pull/18790#discussion_r1612775255
PR Review Comment: https://git.openjdk.org/jdk/pull/18790#discussion_r1612776411
PR Review Comment: https://git.openjdk.org/jdk/pull/18790#discussion_r1612775580
PR Review Comment: https://git.openjdk.org/jdk/pull/18790#discussion_r1612775821


More information about the hotspot-dev mailing list