开发者

Features for profiling concurrent program behaviour in Java

开发者 https://www.devze.com 2023-02-11 06:45 出处:网络
Nowadays there are some profilers which promise to profile concurrent behavior of program execution in order to understand the threaded execution.

Nowadays there are some profilers which promise to profile concurrent behavior of program execution in order to understand the threaded execution.

I am collection features which would be useful for a Java profiler concentrating on profiling concurrency only:

What I've collected so far:

  • cons开发者_JS百科truction of waits-for graphs to detect potential deadlocks

  • time measurement of accessing resources (data-structures, etc.)

  • show states of every thread (alive, interrupted, dead)

  • which thread called which thread for accessing shared ressources (wait, blocked, etc.)

What ideas do you have? Personally I am aiming to unveil some bad programming habits when dealing with concurrency in Java.


Summary statistics for each thread: how much time spend in each state (running, runnable, blocked etc).


Tools for detecting "hot" monitors in order to find where the contention is. For example, show locks sorted by the total time spent waiting for them, with the ability to see the bits of code that held the lock and the bits of code that waited for it.


Any

  • Contended monitor or lock
  • Failed CAS
  • Volatile reads and writes

What would be fantastic would be a way to see shared data that wasn't protected by happens-before and was therefore racy. Hard to do though.


When each thread is blocked, if the thread code is at all complex, simply knowing that it's blocked will not be very informative, even if you can tell which other thread it's waiting for. I would want to know why it's blocked.

The way to tell why it's blocked is to capture its call stack at the time it becomes blocked. Each function call site on the stack gives one link in the chain of reasoning of why it is there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号