简体   繁体   中英

java performance Windows vs Linux

I have developed a Java application that normally run on Linux. It's a POJO application with Swing. Performance is reasonably good.

Now I tried to run it on Windows XP with 2Gb RAM, in a machine with similar or greater potency, and performance is much worse. I observe that it uses 100% CPU.

For example:

  • A process that creates a window very heavy, with many components: Linux 5 seconds, Windows 12.
  • A process that accesses a PostgreSQL DB with a heavy query (the server and the JDBC driver are the same): 23 seconds Linux, Windows 43.

    I tried also with a virtualized Windows machine with similar features, and the result is significantly better!

    Is it normal? What parameters can I assign to improve performance?

Unless you are comparing Linux and Windows XP on the same machine it is very hard to say what the difference is. It could be that while the CPU is faster, the GFX card and disk subsystem is slower.

Java passes all of this IO and GFX acitvity to the underlying OS and the only thing you can do differently is to do less work or work more efficiently. This is likely to make both systems faster, as there is not particular to one OS which you can tune.

尝试运行Java Visual VM(作为JDK的一部分分发):连接到您的应用程序,然后使用CPU Profiler精确确定所有CPU时间的去向。

There may be subtle differences in the behavior of JRE parts (Swing comes to mind), where the JRE responds very unforgiving to a bad practice (like doing thing from the wrong thread in Swing).

Since you have no clues, I would try profiling the same use case in both environments and see if any significant differences turn up where the time is spent. This will hopefully reveal a hint.

Edit: And ensure that you do not run Windows with brakes on (aka. Antivirus and other 'useful' software that can kill system performance).

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