Features for profiling concurrent program behaviour in Java

479 views Asked by At

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:

  • construction 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.

4

There are 4 answers

0
Jed Wesley-Smith On

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.

0
Mike Dunlavey On

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
NPE On

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

0
NPE On

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.