Mac OS 上的 Java 随机减速

Java Random Slowdowns on Mac OS(Mac OS 上的 Java 随机减速)
本文介绍了Mac OS 上的 Java 随机减速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个 Java 程序,用于跨多个处理器执行一组科学计算,方法是将其分解为多个片段并在不同的线程中运行每个片段.这个问题是微不足道的,因此线程之间没有争用或通信.他们访问的唯一常见数据是一些不需要同步访问的共享静态缓存,以及硬盘驱动器上的一些数据文件.线程也不断地写入磁盘,但写入单独的文件.

I have a Java program for doing a set of scientific calculations across multiple processors by breaking it into pieces and running each piece in a different thread. The problem is trivially partitionable so there's no contention or communication between the threads. The only common data they access are some shared static caches that don't need to have their access synchronized, and some data files on the hard drive. The threads are also continuously writing to the disk, but to separate files.

我的问题是,有时当我运行程序时,我的速度非常快,而有时当我运行完全相同的程序时,它运行得非常慢.如果我看到它运行缓慢并且 ctrl-C 并重新启动它,它通常会再次开始快速运行.它似乎在运行的早期就将自己设置为慢速模式或快速模式,并且从不在模式之间切换.

My problem is that sometimes when I run the program I get very good speed, and sometimes when I run the exact same thing it runs very slowly. If I see it running slowly and ctrl-C and restart it, it will usually start running fast again. It seems to set itself into either slow mode or fast mode early on in the run and never switches between modes.

我已将它连接到 jconsole,它似乎不是内存问题.当我发现它运行缓慢时,我尝试将探查器连接到它,但探查器无法连接.我尝试使用 -Xprof 运行,但慢速运行和快速运行之间的转储似乎并没有太大不同.我也尝试过使用不同的垃圾收集器和不同大小的内存空间.

I have hooked it up to jconsole and it doesn't seem to be a memory problem. When I have caught it running slowly, I've tried connecting a profiler to it but the profiler won't connect. I've tried running with -Xprof but the dumps between a slow run and fast run don't seem to be much different. I have tried using different garbage collectors and different sizings of the various parts of the memory space, also.

我的机器是带有条带 RAID 分区的 mac pro.无论是慢还是快,cpu 的使用率都不会下降,如果线程花费太多时间阻塞从磁盘读取,你会预料到,所以我认为这不会是磁盘读取问题.

My machine is a mac pro with striped RAID partition. The cpu usage never drops off whether its running slowly or quickly, which you would expect if threads were spending too much time blocking on reads from the disk, so I don't think it could be a disk read problem.

我的问题是,我的代码有哪些类型的问题会导致这种情况?或者这可能是操作系统问题?我无法在 Windows 机器上复制它,但我没有具有类似 RAID 设置的 Windows 机器.

My question is, what types of problems with my code could cause this? Or could this be an OS problem? I haven't been able to duplicate it on a windows a machine, but I don't have a windows machine with a similar RAID setup.

推荐答案

您可能有线程进入了无限循环.

You might have thread that have gone into an endless loop.

尝试连接 VisualVM 并使用线程监视器.

Try connecting with VisualVM and use the Thread monitor.

https://visualvm.dev.java.net

您可能必须在问题发生之前进行连接.

You may have to connect before the problem occurs.

这篇关于Mac OS 上的 Java 随机减速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Show padding zeros using DecimalFormat(使用 DecimalFormat 显示填充零)
Java decimal formatting using String.format?(使用 String.format 的 Java 十进制格式?)
Sprintf equivalent in Java(Java 中的 Sprintf 等价物)
StAX XML formatting in Java(Java 中的 StAX XML 格式)
Java - format double value as dollar amount(Java - 将双值格式化为美元金额)
Java printf using variable field size?(Java printf使用可变字段大小?)