0

I'm trying to figure out which Java thread is hogging my CPU. From my top's perspective I've found that this LWP is the bottleneck, with 17.8%:

10634 user1+  20   0 6911624 939456  28016 S  0.3  17.8   0:00.65 java

As I understand the processid of the thread, should map the nid attribute of the Java Thread dump:

"RMI Scheduler(0)" #209 daemon prio=9 os_prio=0 tid=0x00007fe71c18a800 nid=0x2c78 waiting on condition [0x00007fe6d35a5000]
"RMI TCP Accept-0" #207 daemon prio=9 os_prio=0 tid=0x00007fe714106000 nid=0x2c74 runnable [0x00007fe6d1f84000]
"Attach Listener" #206 daemon prio=9 os_prio=0 tid=0x00007fe7301ab800 nid=0x2a98 waiting on condition [0x0000000000000000]
"ServerService Thread Pool -- 67" #205 prio=5 os_prio=0 tid=0x00007fe74c126000 nid=0x2a49 waiting on condition [0x00007fe6d38a8000]
"Thread-94" #202 daemon prio=5 os_prio=0 tid=0x00007fe70c0c7800 nid=0x2a43 runnable [0x00007fe6ce995000]
"Weld Thread Pool -- 5" #192 prio=5 os_prio=0 tid=0x00007fe6f8116000 nid=0x2a32 waiting on condition [0x00007fe6ced97000]
. . . . . . . .

However, converting 10640 to Hex does not produce a valid match:

printf -v result1 "%x" "10640"
$ echo $result1
2990

Can you help to convert the pid (10634) to a valid Hex value, as displayed by the nid attribute? Thanks

Carla
  • 3,064
  • 8
  • 36
  • 65
  • `nid` is the Native OS *Thread* ID, not the *Process* ID. You only get one line in *top*, representing the Process. You get many lines in the thread dump, obviously representing Threads. – Andreas Jan 04 '17 at 09:51

1 Answers1

4

In fact, 2990 is the hex representation of (decimal) 10640. Maybe you only want a 0x prefix to be consistent with C/Java/Python notation

 $ printf -v result1 0x%x 10640
 $ echo $result1
 0x2990

 $ printf 0x%x 11340
 0x2c4c

For completeness: you can see this question with its answers to learn how to find native thread id’s spawned by a process on linux.

Community
  • 1
  • 1
Dario
  • 2,673
  • 20
  • 24
  • he wants to match the converted HEX to `nid` in java thread dump. E.g. the 10634(DEC) = 0x298a(HEX), however he cannot find the match. – Kent Jan 04 '17 at 09:51