Find out what many threads are doing from the jstack results

$  jstack 20065 | sed -e ':a;N;s/\n\(\s\+\)\(\S.*\)/ \2/;t a ;P;D'  | grep '^"' | sed -e 's/^"\(\([^0-9 ]\+\)[^"]*\)"\(.*\)/\2 \3/'  | sed -e 's/^\(\S\+\).*\(State: .*\)/\1 \2/' |  sed 's/0x[0-f]\+/0xXXXX/g' | sed 's/thread#[0-9]\+/thread#xx/g' |
sort | uniq -c | sort -rnk1 |  sed 's/^\(\s*[0-9]\)/\n\1/; s/ at /\n          at /g; '

    296 RPC-Thread: State: WAITING (parking)
          at sun.misc.Unsafe.park(Native Method) - parking to wait for  <0xXXXX (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
          at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
          at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
          at com.lmax.disruptor.BlockingWaitStrategy.waitFor(BlockingWaitStrategy.java:45)
          at com.lmax.disruptor.ProcessingSequenceBarrier.waitFor(ProcessingSequenceBarrier.java:55)
          at com.lmax.disruptor.WorkProcessor.run(WorkProcessor.java:110)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)

     12 MutationStage: State: TIMED_WAITING (parking)
          at sun.misc.Unsafe.park(Native Method) - parking to wait for  <0xXXXX (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
          at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
          at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
          at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
          at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1066)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)

     10 Gang  os_prio=0 tid=0xXXXX nid=0xXXXX runnable

      8 Thrift-Selector_ State: RUNNABLE
          at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
          at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
          at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93)
          at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0xXXXX (a sun.nio.ch.Util$2) - locked <0xXXXX (a java.util.Collections$UnmodifiableSet) - locked <0xXXXX (a sun.nio.ch.EPollSelectorImpl)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
          at com.thinkaurelius.thrift.TDisruptorServer$AbstractSelectorThread.select(TDisruptorServer.java:406)
          at com.thinkaurelius.thrift.TDisruptorServer$AbstractSelectorThread.run(TDisruptorServer.java:383)

      6 ReadStage: State: TIMED_WAITING (parking)
          at sun.misc.Unsafe.park(Native Method) - parking to wait for  <0xXXXX (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
          at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
          at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
          at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
          at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1066)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)

      4 C State: RUNNABLE

      2 Thrift-Acceptor_ State: RUNNABLE
          at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
          at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
          at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93)
          at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0xXXXX (a sun.nio.ch.Util$2) - locked <0xXXXX (a java.util.Collections$UnmodifiableSet) - locked <0xXXXX (a sun.nio.ch.EPollSelectorImpl)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
          at com.thinkaurelius.thrift.TDisruptorServer$AbstractSelectorThread.select(TDisruptorServer.java:406)
          at com.thinkaurelius.thrift.TDisruptorServer$AbstractSelectorThread.run(TDisruptorServer.java:383)

...

Recommended Posts

Find out what many threads are doing from the jstack results
Get the value from the array and find out what number it is included in
What if the results of sum and inject (: +) are different?
[Ruby] Forget what attr_reader, attr_writer, attr_accessor are doing many times
config.ru What are you doing?
What are the rules in JUnit?
What you are doing in the confirmation at the time of gem update