RFR: 8350854: Include thread counts in safepoint logging

Xiaolong Peng xpeng at openjdk.org
Tue Mar 4 08:21:57 UTC 2025


On Tue, 4 Mar 2025 06:34:52 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> The PR is to add thread counts in safepoint logging. In recent work, we notice the number of Java thread may affects time to reach/leave safepoint hardly in some cases, but safepoint logging doesn't have thread counts, thread counts are printed only with 'safepoint+stats' log. 
>> 
>> Given in many cases, we only have `safepoint` log enabled, not `safepoint+stats`, it make sense to add thread count to 'safepoint' logging. 
>> 
>> Here is example log output with the change:
>> 
>> [15.240s][info][safepoint      ] Safepoint "ShenandoahFinalMarkStartEvac", Time since last: 3527459 ns, Reaching safepoint: 78666 ns, At safepoint: 821625 ns, Leaving safepoint: 1472167 ns, Total: 2372458 ns, Threads: 3 runnable, 1038 total
>> 
>> 
>> 
>> ### Test
>> - [x] Tire1
>> - [x] Tire2
>
> src/hotspot/share/runtime/safepoint.cpp line 993:
> 
>> 991:      "Leaving safepoint: " JLONG_FORMAT " ns, "
>> 992:      "Total: " JLONG_FORMAT " ns, "
>> 993:      "Threads: " INT32_FORMAT " runnable, " INT32_FORMAT " total",
> 
> Why `INT32_FORMAT` when the fields are just `int`???

Hi David, thanks for the review, I referred to the format used in safepoint [stats log](https://github.com/openjdk/jdk/pull/23838/files#diff-d61020d12394708828d066d097d823180c01b74d35d4c3e369aead062abc11efR913) where format `INT32_FORMAT_W(8)` is used for thread counts, but there is no need print thread count in fixed width with safepoint log, so I removed the fixed width from the format.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23838#discussion_r1978864746


More information about the hotspot-runtime-dev mailing list