Some of you might now I’m working on a multiplayer space shooter called Xtreme Space War. (It’s in the showcase/Action section)
I need some help optimizing… have searched the forum and tried alot of things maybe I’ve missed something.
The problem is when I am running a server and a client on the same computer. After a clean reboot it works smooth. But after having run some other apps (such as Eclipse) the problem appears, and it persists even after closing all other apps.
The best I can do with tweaking flags is to get 6 stutterings of about 0.5 s each with 6 s between them in the client. After that everything runs smoothly. This is a log:
XSW logfile - version 1.0
13.28:48 C: List complete.
13.28:48 C: Test Server (LOCAL), ip=85.224.17.252, port=1253, players=0/20, pingTime=8
13.28:49 C: Connection established.
13.28:50 C: free mem: 39012056
13.28:50 C: free mem: 44990064
13.28:52 C: FrameTime: 520.2136
13.28:58 C: FrameTime: 526.26965
13.29:04 C: FrameTime: 516.5592
13.29:10 C: FrameTime: 513.2217
13.29:16 C: FrameTime: 506.33752
13.29:22 C: FrameTime: 508.01904
13.30:08 C: Server connection closed
The frame time is printed whenever it goes above 40 ms, so in between these problem frames there are alot of other < 40 ms frames.
The flags I am using are:
-XX:CompileThreshold=500
-Xmx48m -Xms48m
-XX:+UseParallelGC
-XX:MaxGCPauseMillis=10
-XX:NewSize=12m
-XX:MaxNewSize=12m
-Xloggc:gc_server.txt
I have set the memory flags pretty high so I know it is not gc causing it. I’ve watched the trace and before entering the gameloop I do a System.gc, after that there is no gc collection occuring the first 30 s… but in this time the stuttering occurs with exactly 6 s interval.
The server is run in its own vm (separate program) using the same flags, and also has no gc occuring.
So, gc should not cause this at all… something else must be doing it, I figured compilation might…
These things I have tried.
-XX:CompileThreshold (with a few different values - seems to do nothing to help the problem)
-Xbatch - same problem
-Xint - same problem but now I get a terrible frame rate (20 fps)
-Xcompile - same problem
turned off all logging (to see if IO blocking might be the issue) - same problem.
Running the client or server on their own works fine. But running both together on the same computer (my laptop) I get these problems. (Well after having the computer running for a couple of days, with alot of apps running I get some similar problems when only running the client, but haven’t tryed optimizing that yet).
I would be happy for any ideas that might help, this is really bugging me.
If you want to help by profiling it yourself let me know, and I can send you a newer version of the game (fixes alot of problems)…
My specs are:
computer: Acer TravelMate 3002
cpu: pentium mobile 1.7 ghz
ram: 2 gb
Windows XP
java 1.5 latest revision