简体   繁体   中英

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). 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. 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.

Areas in the program that are relevant: Pulling packets off a socket Database access (mysql 5.1.45) A ton of file 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.

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?

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)

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. 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:

PS:

Affe's suggestion about NIO is a good one. 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. IMHO...

On the face of it, Linux is not slower than Windows for the same hardware. Before blaming the OS (or Java on the OS), I'd look at other things:

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


Are there any utilities that provide java performance benchmarking across linux and windows?

Not that I'm aware of.

Some other things that might affect performance: - JVM - are you using the same vendors JVM? Same version? Are both 64-bit or 32-bit? - 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? For instance, if iostat has high IO wait times, then it could be an issue with how the drives are configured

There are LOTS of factors that can effect Java performance. Start simple, work backwards. In my mind, simple == basic stats like memory pages and IO performance. If we are talking the EXACT same code, then start identifying the differences (OS obviously, but what else?)

JVisualVM may already be available on your target platforms. An example may be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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