简体   繁体   English

我正在尝试使用Linux vs Windows上的相同Java代码来识别性能差异。 从表面上看,Linux下的性能要差得多

[英]I'm trying to identify performance differences with the same java code on linux vs windows. On the face of it, performance under linux is much worse

I realize that this question is pretty generic, and I'm looking for very general input on how to reconcile performance differences on linux (RedHat 5) vs Windows (2008 Server). 我意识到这个问题是很笼统的,我正在寻找有关如何协调linux(RedHat 5)与Windows(2008 Server)的性能差异的非常一般的建议。 I have a java application that is a collection of multiple services that is processing netflow packets off a wire that seems to be performing at about half the capacity on Linux vs Windows on the exact same hardware. 我有一个Java应用程序,它是多个服务的集合,这些服务正在处理一条线路上的netflow数据包,该功能似乎在完全相同的硬件上的Linux和Windows上的容量大约只有一半。 The application involves pulling packets off a socket, and performing some very simple processing on them, and writing out a condensed output file to be processed downstream by a different C++ application. 该应用程序涉及从套接字中提取数据包,并对它们执行一些非常简单的处理,以及写出压缩的输出文件,以供其他C ++应用程序在下游处理。

Areas in the program that are relevant: Pulling packets off a socket Database access (mysql 5.1.45) A ton of file i/o 程序中相关的区域:从套接字提取数据包数据库访问(mysql 5.1.45)一吨文件I / O

I have very little linux experience as far as optimizations go, and it would be great if someone could point out a few things to watch out for when trying to optimize this for linux that are different than on windows. 就优化而言,我几乎没有linux的经验,如果有人在尝试针对不同于Windows的linux进行优化时指出一些注意事项,那就太好了。

Also, I'm not entirely sure what other information I can give. 另外,我不确定我还能提供什么其他信息。 As in, I know I haven't provided lots of useful information, and I would appreciate questions that point me in the right direction. 在这种情况下,我知道我没有提供很多有用的信息,因此我希望能向我指出正确的方向。

Are there any utilities that provide java performance benchmarking across linux and windows? 是否有任何实用程序可在Linux和Windows上提供Java性能基准测试?

Feel free to shoot me down if the question doesn't make sense, or I'm providing too little information to even ask a useful question. 如果这个问题没有道理,或者我提供的信息太少,甚至无法提出有用的问题,请随时将我击落。

Thanks! 谢谢!

Edit: All the jvm settings are the same (we use the exact same wrapper config files in both cases for the services involved) 编辑:所有jvm设置都相同(在两种情况下,对于所涉及的服务,我们使用完全相同的包装器配置文件)

Edit: I'd like to table this issue for the time being. 编辑:我想暂时解决这个问题。 I have been unable to spend any more significant time exploring this apart from running a basic profiler and comparing the results. 除了运行基本的探查器和比较结果之外,我一直无法花更多的时间进行探索。 The results on both linux and windows look almost identical, apart from a much larger lag in pulling packets off the NIC. 在linux和Windows上的结果看起来几乎相同,除了从NIC提取数据包的滞后要大得多。 I still don't understand why this is the case, or if this is an anomaly related to other network conditions. 我仍然不明白为什么会这样,或者这是否与其他网络状况有关。 I will post more when I get the time to look at this again. 有时间再看一遍时,我将发布更多内容。

Thanks for the answers all! 感谢所有的答案!

Suggestion: find a profiling tool that fits your scenario, and just run it in both environments. 建议:找到适合您情况的分析工具,然后在两种环境中都运行它。

For example, Eclipse TFTP: 例如,Eclipse TFTP:

PS: PS:

Affe's suggestion about NIO is a good one. Affe关于NIO的建议是一个很好的建议。 Admittedly, it begs the question about why there seems to be a performance difference . 诚然,这引出了一个问题,即为什么似乎存在性能差异 But if you're not already using NIO, it could benefit both environments. 但是,如果您还没有使用NIO,则可以使两种环境都受益。 IMHO... 恕我直言...

On the face of it, Linux is not slower than Windows for the same hardware. 从表面上看,对于相同的硬件,Linux并不比Windows慢。 Before blaming the OS (or Java on the OS), I'd look at other things: 在指责操作系统(或操作系统上的Java)之前,我将看一下其他事情:

  • Is the hardware the same? 硬件是否相同? Same processors specs? 处理器规格相同吗? Same amount of memory? 相同的内存量? Same disc specs? 相同的光盘规格?

  • Is it a problem with the database? 数据库有问题吗? Are the Windows and Linux systems talking to the same database instance? Windows和Linux系统是否在同一个数据库实例通信? Are they talking to it the same way. 他们是否以同样的方式说话。 If the database instances are different, have they been configured the same? 如果数据库实例不同,是否配置相同? Have they been tuned? 他们已经调好了吗?

The solution to this kind of problem often involves turning on performance monitoring, profiling, etc and analysing the systems' behaviour to see where the bottlenecks are. 解决此类问题的方法通常包括打开性能监视,性能分析等,并分析系统行为以查看瓶颈所在。

IMO, you need to figure out where the bottlenecks really are before spending (wasting) time on some theory that (for instance) using NIO will fix the problem. IMO,您需要花一些时间(浪费)一些理论(例如,使用NIO可以解决问题)之前弄清楚瓶颈的真正位置。


Are there any utilities that provide java performance benchmarking across linux and windows? 是否有任何实用程序可在Linux和Windows上提供Java性能基准测试?

Not that I'm aware of. 不是我知道的。

Some other things that might affect performance: - JVM - are you using the same vendors JVM? 其他可能影响性能的因素:-JVM-您是否使用相同的供应商JVM? Same version? 相同版本? Are both 64-bit or 32-bit? 都是64位还是32位? - Kernel issues: Are you running a custom kernel? -内核问题:您正在运行自定义内核吗? Correctly compiled for your processor? 为您的处理器正确编译了吗? - What are the CLI performance tools (top, ntop, iostat, vmstat) telling you on Linux? -在Linux上告诉您什么CLI性能工具(top,ntop,iostat,vmstat)? For instance, if iostat has high IO wait times, then it could be an issue with how the drives are configured 例如,如果iostat的IO等待时间较长,则可能是如何配置驱动器的问题

There are LOTS of factors that can effect Java performance. 有很多因素会影响Java性能。 Start simple, work backwards. 从简单开始,向后工作。 In my mind, simple == basic stats like memory pages and IO performance. 在我看来,简单的==基本统计信息,例如内存页面和IO性能。 If we are talking the EXACT same code, then start identifying the differences (OS obviously, but what else?) 如果我们使用的是完全相同的代码,则开始识别差异(显然是OS,但还有什么?)

JVisualVM may already be available on your target platforms. JVisualVM可能已在您的目标平台上可用。 An example may be found here . 一个例子可以在这里找到。

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

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