简体   繁体   English

在Java中分析并发程序行为的功能

[英]Features for profiling concurrent program behaviour in Java

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: 我正在收集仅对概要分析并发性集中的Java探查器有用的功能:

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. 我个人的目的是在处理Java并发时揭露一些不良的编程习惯。

每个线程的摘要统计信息:每个状态(运行,可运行,已阻止等)花费多少时间。

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 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. 堆栈上的每个函数调用站点都在其为什么存在的推理链中给出了一个链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM