RFR: JDK-8306510: Print number of threads and stack sizes in error reports [v4]

Gerard Ziemski gziemski at openjdk.org
Fri Apr 28 16:17:52 UTC 2023


On Fri, 28 Apr 2023 06:25:57 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> To analyze OOM situations, the number of threads and their stack sizes are useful. NMT tells us, but NMT may be disabled.
>> 
>> We already print threads and stacks. Today one could count lines and calculate stack sizes via stack base and end address. But that can get old real quick. It would be helpful to see the number of threads and their stack sizes printed out. 
>> 
>> ---------
>> 
>> Patch does that, and also adjusts indentation a bit to make the output more readable. I'm open to leaving out that part if folks object. The patch only affects printing hs-err files, no other printouts should be affected (I tested jcmd Thread.print and output is unchanged).
>> 
>> Tests: manually ran runtime/ErrorHandling and serviceability/dcmd on Linux x64 and x32.
>> 
>> Changed output looks like this:
>> 
>> before:
>> 
>> Java Threads: ( => current thread )
>> =>0x00007fe26c028d50 JavaThread "main" [_thread_in_vm, id=229773, stack(0x00007fe270f4e000,0x00007fe27104f000)]
>>   0x00007fe26c30bca0 JavaThread "Reference Handler" daemon [_thread_blocked, id=229780, stack(0x00007fe2309fc000,0x00007fe230afd000)]
>>   0x00007fe26c30d670 JavaThread "Finalizer" daemon [_thread_blocked, id=229781, stack(0x00007fe2308fb000,0x00007fe2309fc000)]
>>   0x00007fe26c3178b0 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=229782, stack(0x00007fe2307fa000,0x00007fe2308fb000)]
>>   0x00007fe26c319030 JavaThread "Service Thread" daemon [_thread_blocked, id=229783, stack(0x00007fe2306f9000,0x00007fe2307fa000)]
>>   0x00007fe26c31a710 JavaThread "Monitor Deflation Thread" daemon [_thread_blocked, id=229784, stack(0x00007fe2305f8000,0x00007fe2306f9000)]
>>   0x00007fe26c31c480 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=229785, stack(0x00007fe2304f7000,0x00007fe2305f8000)]
>>   0x00007fe26c31dd10 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=229786, stack(0x00007fe2303f6000,0x00007fe2304f7000)]
>>   0x00007fe20007aa70 JavaThread "C1 CompilerThread1" daemon [_thread_blocked, id=229787, stack(0x00007fe230215000,0x00007fe230316000)]
>>   0x00007fe20011b4d0 JavaThread "C1 CompilerThread2" daemon [_thread_blocked, id=229788, stack(0x00007fe230114000,0x00007fe230215000)]
>>   0x00007fe20011c880 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=229789, stack(0x00007fe230013000,0x00007fe230114000)]
>>   0x00007fe26c432530 JavaThread "Notification Thread" daemon [_thread_blocked, id=229790, stack(0x00007fe1f7eff000,0x00007fe1f8000000)]
>> 
>> Other Threads:
>>   0x00007fe26c290f00 VMThread "VM Thread" [stack: 0x00007fe23106f000,0x00007fe23116f000] [id=229779]
>>   0x00007fe26c434920 WatcherThread "VM Periodic Task Thread" [stack: 0x00007fe1f7dff000,0x00007fe1f7eff000] [id=229791]
>>   0x00007fe26c05aeb0 WorkerThread "GC Thread#0" [stack: 0x00007fe2408ac000,0x00007fe2409ac000] [id=229774]
>>   0x00007fe26c06c320 ConcurrentGCThread "G1 Main Marker" [stack: 0x00007fe2407aa000,0x00007fe2408aa000] [id=229775]
>>   0x00007fe26c06d490 WorkerThread "G1 Conc#0" [stack: 0x00007fe2406a8000,0x00007fe2407a8000] [id=229776]
>>   0x00007fe26c12eae0 ConcurrentGCThread "G1 Refine#0" [stack: 0x00007fe2312f4000,0x00007fe2313f4000] [id=229777]
>>   0x00007fe26c12fc40 ConcurrentGCThread "G1 Service" [stack: 0x00007fe2311f2000,0x00007fe2312f2000] [id=229778]
>> 
>> now:
>> 
>> 
>> Java Threads: ( => current thread )
>> =>0x00007f0ac4028d50 JavaThread "main"                              [_thread_in_vm, id=239089, stack(0x00007f0aca01d000,0x00007f0aca11e000) (1028K)]
>>   0x00007f0ac430bca0 JavaThread "Reference Handler"          daemon [_thread_blocked, id=239096, stack(0x00007f0a9803e000,0x00007f0a9813f000) (1028K)]
>>   0x00007f0ac430d670 JavaThread "Finalizer"                  daemon [_thread_blocked, id=239097, stack(0x00007f0a8998f000,0x00007f0a89a90000) (1028K)]
>>   0x00007f0ac43178b0 JavaThread "Signal Dispatcher"          daemon [_thread_blocked, id=239098, stack(0x00007f0a8988e000,0x00007f0a8998f000) (1028K)]
>>   0x00007f0ac4319030 JavaThread "Service Thread"             daemon [_thread_blocked, id=239099, stack(0x00007f0a8978d000,0x00007f0a8988e000) (1028K)]
>>   0x00007f0ac431a710 JavaThread "Monitor Deflation Thread"   daemon [_thread_blocked, id=239100, stack(0x00007f0a8968c000,0x00007f0a8978d000) (1028K)]
>>   0x00007f0ac431c480 JavaThread "C2 CompilerThread0"         daemon [_thread_blocked, id=239101, stack(0x00007f0a8958b000,0x00007f0a8968c000) (1028K)]
>>   0x00007f0ac431dd10 JavaThread "C1 CompilerThread0"         daemon [_thread_blocked, id=239102, stack(0x00007f0a8948a000,0x00007f0a8958b000) (1028K)]
>>   0x00007f0a5808da10 JavaThread "C1 CompilerThread1"         daemon [_thread_blocked, id=239103, stack(0x00007f0a892b9000,0x00007f0a893ba000) (1028K)]
>>   0x00007f0a5811e450 JavaThread "C1 CompilerThread2"         daemon [_thread_blocked, id=239104, stack(0x00007f0a891b8000,0x00007f0a892b9000) (1028K)]
>>   0x00007f0a5811f800 JavaThread "C1 CompilerThread3"         daemon [_thread_blocked, id=239105, stack(0x00007f0a890b7000,0x00007f0a891b8000) (1028K)]
>>   0x00007f0ac443a4b0 JavaThread "Notification Thread"        daemon [_thread_blocked, id=239106, stack(0x00007f0a88fb6000,0x00007f0a890b7000) (1028K)]
>> Total: 12
>> 
>> Other Threads:
>>   0x00007f0ac4290f00 VMThread "VM Thread"                    [stack: 0x00007f0a98141000,0x00007f0a98241000] (1024K) [id=239095]
>>   0x00007f0ac443c8a0 WatcherThread "VM Periodic Task Thread" [stack: 0x00007f0a88eb6000,0x00007f0a88fb6000] (1024K) [id=239107]
>>   0x00007f0ac405aeb0 WorkerThread "GC Thread#0"              [stack: 0x00007f0ac8929000,0x00007f0ac8a29000] (1024K) [id=239090]
>>   0x00007f0ac406c320 ConcurrentGCThread "G1 Main Marker"     [stack: 0x00007f0ac8827000,0x00007f0ac8927000] (1024K) [id=239091]
>>   0x00007f0ac406d490 WorkerThread "G1 Conc#0"                [stack: 0x00007f0ac8725000,0x00007f0ac8825000] (1024K) [id=239092]
>>   0x00007f0ac412eae0 ConcurrentGCThread "G1 Refine#0"        [stack: 0x00007f0a98462000,0x00007f0a98562000] (1024K) [id=239093]
>>   0x00007f0ac412fc40 ConcurrentGCThread "G1 Service"         [stack: 0x00007f0a98360000,0x00007f0a98460000] (1024K) [id=239094]
>> Total: 8
>
> Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains six commits:
> 
>  - merge
>  - davids comments
>  - feedback
>  - Merge branch 'openjdk:master' into JDK-8306510-Print-number-of-threads-and-stack-sizes-in-error-reports
>  - start
>  - JDK-8306510-Print-number-of-threads-and-stack-sizes-in-error-reports

If it were me I would also move the Java's thread running status at the end, especially because it is variable length, so that we would have:


164 =>0x00007f9328028d10 JavaThread "main"                              [id=104806, stack(0x00007f932fdf0000,0x00007f932fef1000) (1028K), _thread_in_vm]

vs


176   0x00007f932822a3e0 VMThread "VM Thread"                           [id=104812, stack:(0x00007f92e7e7f000,0x00007f92e7f7f000) (1024K)]


But I am not going to insist on that.

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

PR Comment: https://git.openjdk.org/jdk/pull/13556#issuecomment-1527770913


More information about the hotspot-runtime-dev mailing list