Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Need help optimizing to get rid of stutterings.  (Read 5822 times)
0 Members and 1 Guest are viewing this topic.
Offline Aramaz

Junior Member




Java Games Rock!


« Posted 2006-01-24 13:08:34 »

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

Play XSW: www.xsw.se
Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #1 - Posted 2006-01-24 15:05:54 »

Dump the CompileThreshold Smiley  Plus you might want to try using -server and see if that helps...
Offline Aramaz

Junior Member




Java Games Rock!


« Reply #2 - Posted 2006-01-24 15:57:02 »

I have tried without compile threashold (actually didn't use it until some tests today), but it was the same.

It's important that it will without server vm's as players themselves should be able to run both server and client without problem (and I don't want to ask them to download server vm).

Anyways, tried server vm and it did not help.

thanx for the suggestions though.

Play XSW: www.xsw.se
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline HamsterofDeath

Junior Member




Java games rock!


« Reply #3 - Posted 2006-01-24 17:08:54 »

use a profiler to check if theres a performance leak...
use another vm (bea jrockit), or java6

could it be the JIT optimizing the code?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #4 - Posted 2006-01-25 06:58:52 »

Are you running J2SE 5? If so could you try upgrading to 5.0u6? There was a problem with earlier 5.0 update releases where certain threads' priorities were being set too high which could actually interfere with other applications as well as other threads in the same application.
Offline Aramaz

Junior Member




Java Games Rock!


« Reply #5 - Posted 2006-01-25 12:05:37 »

Now I upgraded to 5.0u6... still the same. I find it very weird that it is always at 6 seconds interval it happens, no matter what settings I use, and after 5 - 6 pauses it disappears.

I tested it just now on my older comp, which has a better graphics card, and there were no problems, it ran without any stutter even though I had several big apps running in the background.

So, maybe it wont be a problem for most people, as most doesn't do gaming on a laptop with integrated graphics... although it would be nice to have it running smooth during development as well.


Play XSW: www.xsw.se
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #6 - Posted 2006-01-25 15:49:24 »

Could you please remove all of the GC-related flags? It looks like you're setting a potentially unreachable pause time goal, and your fixing of the min and max size is defeating the GC's ability to size the heap to the size of the working set. BTW, 48 MB is not very large; the default maximum heap size is 64 MB, so you're actually constraining the app to run in less memory than it would otherwise have available (assuming the working set is large).
Offline Aramaz

Junior Member




Java Games Rock!


« Reply #7 - Posted 2006-01-25 17:15:30 »

It  was large compared to what I was using previously, 16 mb Wink

I read somewhere that fixing the rate would make less stuttering because then it would avoid alot of resizing and copying. This article led me to mess with some of these parameters: http://fivedots.coe.psu.ac.th/~ad/jg/appC/index.html

Anyways, I removed all the flags... and looking at the gc logs I got even less gc... after the initial bunch of collections and after a big System.gc, the first other gc occured 50 s later.

Thanx for the tip, the gc doesn't seem to benefit from the flags I was using at all. The same stuttering problem remains though. Every 6 seconds for a while then it dissappears. The more apps I've run in the background, and the longer time they've run seems to affect the duration before the stuttering disappears. After a clean reboot I get no stuttering at all...

Play XSW: www.xsw.se
Offline Jeff

JGO Coder




Got any cats?


« Reply #8 - Posted 2006-01-29 22:43:17 »

It  was large compared to what I was using previously, 16 mb Wink

<snip>

 After a clean reboot I get no stuttering at all...

Are you sure you dont have the heap set TOO large?

This sounds to me like you are encountering swapping.  Watch the disk light and see if it is flickering when you get your stutters.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Aramaz

Junior Member




Java Games Rock!


« Reply #9 - Posted 2006-02-03 23:12:13 »

Could I be getting disk swaps even without any flags? I use no paging file at all (2 gb ram), can it start swapping things even though I don't use a paging file?

Anyways, I'll check to see if it does any swapping.

Play XSW: www.xsw.se
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #10 - Posted 2006-02-04 06:01:01 »

Sure. 

If you are using all but 1 byte of your available memory in other programs then as soon as you use mroe then 1 byte of your heap, you start swapping.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Raghar

Junior Member




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #11 - Posted 2006-02-04 18:04:20 »

Could I be getting disk swaps even without any flags? I use no paging file at all (2 gb ram), can it start swapping things even though I don't use a paging file?

Anyways, I'll check to see if it does any swapping.

Are you nuts? Swap file is there for reasons. One of them is freeing of memory from unnecessary drivers and other silly stuff that OS loads into memory. (It's often 415 MB on my computer.)

Of course OS could do things like deleting tmp files, updating registers, and recording your missbehaviour into the log file. Try to start more clients and server on the same computer, and try to test it also on Linux and other configurations.
Offline Aramaz

Junior Member




Java Games Rock!


« Reply #12 - Posted 2006-02-04 19:00:21 »

Nuts? Hoho, I'm not nuts... why free memory when I have 2 gb ram? I think windows xp does a really poor job of handling the swap file... After going to 2 gb programs would start swapping out after not being used for a little while, so I have to wait for them to swap back in even though I have loads of free memory. The reason why I upgraded ram was to get rid of the swaps, then when I noticed there was still alot of swapping I disabled the swap file and it now works like a charm. I generally have alot of applications loaded, and the day is running for several days. I want to be able to swap between the programs instantly without having to wait for them to be read from disk. I use a laptop with a pretty slow harddrive so swapping is very annoying, after disabling the page file I can instantly change program without any delay. And it has caused me no problem whatsoever...

Even when running alot of programs I seldom have less than 1 gb of memory free, so the page file really isn't neccessary. So I don't think I'm nuts, I just want to get the best performance possible from my computer, and without page file it is a lot faster. If the paging was implemented correctly there would be no problem... but it doesn't seem to be done right in xp...

Anyways... when running on my wife's desktop computer (my old one...) I don't get the same problems. More clients will cause the same stutterings. After running the computer for many days I get stutterings while only running the client also. No other people seems to get these stuttering problems with my game though, so I've put investigation of the problem on ice...

Play XSW: www.xsw.se
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #13 - Posted 2006-02-04 21:28:26 »

Microsoft appears to have the concept of virtual memory backwards.. they tend to force things into secondary storage in order to make the least use of RAM. Smiley  It's almost comical how bad VM on Windows is.

Offline Aramaz

Junior Member




Java Games Rock!


« Reply #14 - Posted 2006-02-04 21:35:56 »

agreed! That's why I don't use a page file  Roll Eyes

Play XSW: www.xsw.se
Offline princec

JGO Kernel


Medals: 366
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #15 - Posted 2006-02-05 12:10:08 »

I used to turn the page file off but have since found that it's a little better with it turned on most of the time, especially with KeepResident installed in Eclipse Smiley I also use LargeSystemCache under XP which favours file IO cacheing over apps. But seeing as mostly I only ever have Titan Attacks, Eclipse and Opera running this is no bad thing.

Cas Smiley

Offline Raghar

Junior Member




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #16 - Posted 2006-02-05 21:18:27 »

Random program failures isn't nice thing. Just because MS is unable to create reasonable memory usage analisys, doesn't mean swap file is the bad thing TM. Obviosly in majority of cases you will not notice absence of swap file if you have 2GB memory. However when 3 - 4 programs would go nuts, you'd have a few nice, or but ugly crashes. Or you can play a sim game, and in other thread Civ4. Crash is nearly sure without swap file.

Then again windoze on a 32 bit computer limits user space to 2GB adress space, the other 2GB is for windoze. 64 bit computers doesn't have this ugly limit, so caching on HD will be less needed for games. (And OS without swap would guarantee crash.) Advanced AI is memory eater. 64 bit pointers are not free either.


Offline Riven
« League of Dukes »

JGO Overlord


Medals: 783
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #17 - Posted 2006-02-05 23:12:36 »

Can't you put the 2GB swapfile on a RAM-disk then? Grin

* Riven propably missed the point Wink

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #18 - Posted 2006-02-06 01:42:49 »

* darkprophet thinks the whole idea of HD/Ram business will become obselete once a big enough flash disc drive is created (6Gb at the moment)

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #19 - Posted 2006-02-07 03:43:43 »

* swpalmer thinks flash memory speeds are still slow compared to hard drives.  Maybe the new holographic storage will help Smiley

Offline Mr_Light

Senior Member




shiny.


« Reply #20 - Posted 2006-02-08 11:25:51 »

take one of those cards with sata interface and DDR2 ram put it in raid array. horray.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline pepe

Junior Member




Nothing unreal exists


« Reply #21 - Posted 2006-02-10 14:29:38 »

Storing on flash memory is better if you don't write too much.
That memory is pretty short lived when you have to do that sort of operations. IIRC, the MTBF for each bits is around 100k writes.
That makes much when you write some mp3s from time to time and pass most of the time reading them, but for a swap/HD replacement, you'd avoid it at all costs.

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (16 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (34 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (20 views)
2014-08-16 06:20:21

Tekkerue (31 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (44 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!