Wednesday, April 6, 2011

Please point me the tools or the way to monitor which thead in running in the millisecond level

Hi ,

Please point me the tools or the way to monitor which thead in running in the millisecond level? Thanks.

Suppose I have 3 thread running , and I want infomation like below:

 0 - 20ms  thread1 
20 - 40ms  thread2 
40 - 50ms  thread1 
50 - 70ms  thread3

NOTES: I perfer to solve this problem without hacking into kernel.

EDIT :

  1. in MIPS platfrom with 2.6.21 Linux Kernel

  2. command TOP can provide some information about thread but not too much.

From stackoverflow
  • You can use LTTng to trace scheduling activity (along with lots of other things!) with a suitably configured kernel.

    That said, I looked at your nabble link - your real problem seems to be that your write thread is blocking the read thread, right? One thing to consider trying would be to use a database that supports concurrent reads and writes. Or use a locking protocol to block the write thread when the read thread is active.

    For example, you could have a mutex, condvar, and a want_read value. Before each write, the write thread takes the mutex and checks the wants_read value. If it's nonzero, it blocks on the condvar. Meanwhile, the read thread will increment wants_read under the mutex when it begins, and, when done, decrements it and broadcasts on the condvar. This should cause the write thread to block as soon as is safe when the read thread wants in.

    pierr : It's powerful. But It might take me 2 weeks to set this up..
    pierr : The write thread will slow the search time ,and other busy thread seems also likely to slow the search time. That is the things I want to confirm.
  • Take a look at the Performance Inspector tools.

  • For your specific problem you mentioned in comment, thread without usleep will make a thread busy which will take much of the processor resource. Then you will get a slow database search response.

    For general thing if you want check the thread schedule sequence, and do not want to bother install lttng, you can a trick I used. I add some simple syscall like open, close, time with invalid parameter to the thread's key path (which is low overhead compare to printf, and printf sometimes involved with thread lock), and then you can use strace tool to track all these threads. Check the strace log, you can see when they are scheduled in when other thread are sheduled in. Then you will get a general idea what the thread take most of the time to do, and which thread take most of the system's time.

    Lttng is definitely the best tool for such problem only if you can get it work.

    pierr : It is a cool trick! I am trying it to see if I can get any clue.
  • Intel Concurrency Checker will work on windows and linux. I haven't used it, so I don't know a lot of details, but I have heard that it will do performance measurements. It might be worth a try.

0 comments:

Post a Comment