Due to some external TD analyzer tools throw exceptions, i consider to write some tiny scripts to capture some data from thread dump log.
I use Awk to achieve this:
State1 : in Object.wait()
$ awk '($1~/"http-0.0.0.0/)&&$6=="in" {print $6,$7, i++}' Threaddump_1_Original.txt
State2 : waiting for monitor entry/ waiting on condition
$ awk '($1~/"http-0.0.0.0/)&&($6~/waiting/) {print $6,$7, i++}' Threaddump_1_Original.txt
State3: runnable
$ awk '($1~/"http-0.0.0.0/)&&($6~/runnable/) {print $6,$7, i++}' Threaddump_1_Original.txt
i got the total number of each thread state first(BTW it is just related to Http thread only),
before tuning my application code:
in Object.wait() --------15
waiting for monitor entry ----------23(waiting to lock)
runnable------------4
After Tuning Phase 1:
in Object.wait() --------16
waiting for monitor entry ----------20(waiting to lock)
runnable------------6
After tuning Phase 2:
in Object.wait() --------30
waiting for monitor entry ----------3(waiting to lock)
runnable------------9
when we did tuning work, i will use scripts to seperate the log file according to different thread state,for example:
$ awk 'RS="\n\n",FS="\n" {if(($1~/http-0.0.0.0/)&&($1~/waiting\ on/)) {print $0,i++}}' ThreadDumpA.txt >TDlog1.txt
This may help dev to focus on the real problem in thread dump and improve their efficiency, if you have any other great idea to do this kind tuning, please leave your comments here :)
Thursday, January 08, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment