8

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?

1
  • what was the filesystem being used ? if your virtualized windows is on ext3/4, it could explain why your virtualized windows is performing better. File I/O on windows+ntfs on lot of files is often really slow when compared to linux. Commented Aug 9, 2012 at 9:28

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Try running Java Visual VM (which is distributed as part of the JDK): attach to your application, then use the CPU Profiler to determine precisely where all that CPU time is going.

2 Comments

I tried to profile with VisualVM. In Linux it runs OK, but in Windows hangs (99% CPU used constantly by nbexec.exe, that I think is a VisualVM program).
VisualVM hung before you even got to the profiler? It sounds like something's messed up with your Win XP machine then. You'll need to troubleshoot that I think, so I can't offer much else but a few guesses... (Try again on a non-VM Windows machine if you want convincing first. Scan for viruses. Make sure you don't have 2 antivirus / firewalls running. Clean Java install. Think about graphics drivers. Disable Direct3d using -Dsun.java2d.d3d=false. That kind of jazz.)
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.