程序生成的线程的处理器利用率
我有一个 java 程序,它会产生多个线程,例如 10-20 个线程。该程序计划在具有 32 个处理器的机器上运行。
我很想知道这些线程是否会利用所有处理器的能力。
Solaris是环境;这有什么区别吗?
I have a java program which spawns multiple threads say, 10-20 threads. This program is scheduled to be run on a machine that has 32 processors.
I am keen to know if all the processors' power would be utilized by these threads.
Solaris is the environment; does that make any difference?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个好的分析器应该告诉你这一点。如果线程是计算密集型的,那么是的,您将使用与线程一样多的内核,如果您在执行 I/O 或争用时被阻止,则内核数量将少于该值。
鉴于您不在 Windows 上,以下内容不适用,但一个不错的分析器仍然应该能够提供给定时间段内进程消耗的 CPU 周期的测量结果...
如果您在 Windows 上很好用的免费工具是 Windows Performance Toolkit (xperf),它现在是平台 sdk 的一部分。它将显示一段时间内每个线程或进程消耗的处理器周期(而不是仅仅经过的时间)。
A good profiler should tell you this. If the threads are compute bound, then yes you will use as many cores as you have threads, if you are blocked doing I/O or on contention it will be less than that.
Given that you aren't on Windows, the following doesn't apply, but a decent profiler should still be able to provide a measurement of CPU cycles burned by your process for a give period of time...
If you are on Windows a good free tool to use is the Windows Performance Toolkit (xperf) which is now part of the platform sdk. It will show you the processor cycles burned for each thread or process for a period of time (as opposed to just elapsed times).