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

Calvin Cheung ccheung at openjdk.org
Wed Jun 12 05:30:15 UTC 2024


On Wed, 12 Jun 2024 02:39:39 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> The if-condition could be something like:
>> 
>> 
>> if (log_is_enabled(Info, perf, class, link) ||
>>      log_is_enabled(Info, perf, xxx, yyy) ||
>>      ...)
>> 
>> 
>> Regarding which stream to pass in, with my proposed change in `log_vm_stats` above, the current fix would look like when calling from threads.cpp:
>> `log_vm_stats(false /* use_tty */);`
>> when calling from java.cpp:
>> `log_vm_stats(true /* use_tty */);`
>> 
>> Or do you prefer not having the `log_vm_stats` function and calling `ClassLoader::print_counters` directly?
>> If so, we don't need the compound `if` conditions in the above.
>
> The problem is that the two different logging configurations could have been given different destinations and need not write to the same "stream".

I think it's better not to have `log_vm_stats` but calling `ClassLoader::print_counters` directly. Otherwise, in `log_vm_stats`, it needs to check every -Xlog:perf+... tag like the following:


void log_vm_stats(bool use_tty) {
  LogStreamHandle(Info, perf, class, link) log;
  if (log.is_enabled()) {
    outputStream* st = use_tty ? tty : &log;
    ClassLoader::print_counters(st);
  }
  LogStreamHandle(Info, perf, xxx, yyy) log2;
  if (log2.is_enabled()) {
    outputStream* st = use_tty ? tty : &log2;
    XXX::print_counters(st);
   }
  ...
}


I've pushed another commit without `log_vm_stats`.
Also checked the performance using the PetClinic app which loads more than 17,000 classes during boot up. Not much performance difference was observed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18790#discussion_r1635834291


More information about the hotspot-dev mailing list