I am getting significant performance differences between the two machines when running the graphical part of a game (2D shoot-em up) that I am developing (using Java, Slick2D and dyn4j) and can't work out why this is happening. Both machines are more or less identical in setup other than the hardware.
System Setups
Dekstop - custom-built Intel Core2 Quad Q6600 @ 2.4Ghz with Intel D975XBX2 motherboard, graphics: NVidia GeForce 7300 SE/7200 GS (driver version 9.18.13.908 dated 30/01/2015)
Laptop - Toshiba Satellite L450D with AMD Athlon X2 Dual-Core QL-64 @ 2.1Ghz, graphics: ATI Radeon HD 3200 (driver version 8.634.1.0 dated 27/072009)
Both machines run Windows Home Premium 64-bit and have 8Gb RAM installed. Both have Netbeans 8.0.2 installed and use JRE/JDK 8.0.40. Both Netbeans installs have the same (default installed) start-up options as below.
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m
J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true
-J-java2d.noddraw=true -J-Dsun.java2d.dpiaware=true
-J-Dsun.zip.disableMemoryMapping=true"
I have recently done a clean build on my desktop machine due to a problem with Windows update; the machine only has music studio software and java development stuff installed with no junk whatsoever.
The laptop is a general "install anything you want" machine and has had all sorts on it since I bought it several years ago.
Performance
Desktop: on first run after boot up and starting Netbeans the game normally runs fine. Then after a short number of runs or amount of time (hard to pin this down) performance drops to 10FPS. When performance is poor the CPU is running between 25-30% and Java is taking up around 25% of the available CPU. For an example of the variable performance, I just rebooted the machine and ran the code – no problem. Re-ran it 5 times and still no problem. Browsed the code for 5 minutes and made a 1 line change (added a “- 1” to a sum), re-ran the code and it runs at 10FPS.
Laptop: the game always runs at 60 FPS (it is restricted to this rate in the code). The CPU is running at around 30-40% and Java is taking between 13% and 35-40% (seems to be bounce around a bit). I never have any performance problems on the laptop.
Note that I have run a standalone, compiled version of the game on Dropbox and have run this on both machines and get the same results, which suggests to me that this is a JVM issue rather than a Netbeans one..?
Memory Usage
I have tracked memory usage to see if this is a swapping issue and it doesn’t appear to be – the data below shows memory usage on both machines when running the app. I have included startup and good/bad performance info for the Desktop for completeness.
Desktop:
- 1st boot + Netbeans = Total (8189), Cached (1028), Available (6280), Free (5326)
- 1st run app in Netbeans = Total (8189), Cached (1267), Available (5868), Free (4837) – FPS = 60
- Run app in Netbeans (low FPS) = Total (8189), Cached (1484), Available (5441), Free (4204) – FPS = 10
Laptop:
- Run app in Netbeans = Total (7934), Cached (2367), Available (5933), Free (3660) – FPS = 60
Options Explored
As I mentioned earlier, I have run the app both in Netbeans and as a standalone jar and had the same results. This suggests it isn't a Netbeans issue to me.
The fact that both machines have the same Netbeans config/memory options suggest that memory config isn’t the problem also..?
The project is stored in a Dropbox folder and shared between both machines so I am running the exact same code/project on both machines with the same installed libraries in each case. (I am using dyn4j version 3.1.11 and Slick2D build 237 with LWJGL 2.9.0)
I have found one similar thread on here (see below) and this suggests a possible problem is the graphics drivers and to run graphics tests on each machine. I have a graphics test app that I developed to test different methods for copying and drawing large images between buffers and the screen. This runs twice as fast on my desktop as it does on the laptop, which suggests graphic performance should be ok..?
How to approach Java 2D performance variations between different computers?
I have tried adding “–J –Dsun.java.opengl=true” either in the netbeans.conf file or as a Run VM option, but with no effect. I assume the use of Slick2D means that I am using opengl rendering anyway and don't need this option.
Does anyone have any idea what the problem might be or how I might explore this further? My desktop is my primary development machine and the fact that it isn't working is a real problem for me.