Page 1 of 2
Game is slow...C# runtime issues?
Posted: Sat Apr 14, 2012 11:19 pm
by foul_owl
First, I just want to say that this project kicks ass. I appreciate all the hard work done by the devs!
Running into some issues here:
*OS is Windows 7 Ultimate
*Machine is 3 Ghz AMD with 2 Gb RAM
*Video card is Geforce 460 GTX
*I can play any games written in C++ and OpenGL and get a great framerate. (eg, sauerbraten, ~60 fps at 1920x1080.
*When I load up OpenRA however, my CPU usage spikes to 100%, and the game slows to a crawl, even with just the menu screen.
I am afraid that this issue is due to the C# runtimes. I have heard many folks say that C# is just too slow for serious game development (I'm not saying switch to C++ here, just throwing this out there as the culprit)
Any ideas on debugging the C# runtime slowness? Maybe run some benchmarks comparing OpenGL stress testing (nearly) identical code in C# and C++?
How do I get OpenRA to print the framerate?
Thanks!! And again, thanks for the hard work here.
Posted: Tue May 01, 2012 12:28 pm
by ddd
I think I answered someone in IRC about it.
If your notebook doesn't show long battery life under OpenRA load you can
do several things:
1. Turn off "Show Shellmap" item under General tab of Settings menu.
2. Edit ~/.openra/settings.yaml in the "Graphics:" section to add
framelimiter. Add "CapFramerate: True" string there to enable framelimiter.
The default setting is 60 frames per second. You can change it's value by
adding "MaxFramerate: 70", for example, string in that section. Be careful
with special tab symbols at the beginning of the strings. Don't forget to
backup your settings file.
OpenRA usually uses full CPU + GPU load. And gives you like 300-600 fps or even more on modern GPUs. You can see fps frequency by adding a patch. There's an example of it there:
https://github.com/cerebrum/dr/blob/mas ... 1023.patch
It is only needed to show fps rate by debug messages. And you have to modify it with accordance with a new fps patch in the openra tree if you wanna see actual fps rate.
Posted: Tue May 01, 2012 1:05 pm
by Matt
As
Microsoft XNA Game Studio 4.0 and their XNA Framework is based on .Net and C# I don't think it is too slow for games. I had some performance issues when playing with bots on an Island scenario and they could not reach me via the land way. The pathfinding algorithm made the game repeatedly pause for >1s.
Posted: Thu Jul 12, 2012 11:37 pm
by foul_owl
I didn't post in IRC about this issue.
Still having problems here. Not doing any path finding AFAIK, just showing the menu. Haven't patched to show FPS, but from cursor lag it appears to be less than 10 fps.
Unfortunately it is unplayable for me at this point.
Any debug info I can provide here? Any CPU profiling I can do? Please give me instructions. Thanks!
Posted: Fri Jul 13, 2012 12:04 am
by foul_owl
Ok, I tried setting up OpenRA on another machine in order to try and get more debug info.
This machine is:
CPU: Intel Atom N455
1 gig of ram
OS: Ubuntu 11.10
Window manager is fluxbox (nice and light)
Video card supports OpenGL, glxgears runs nice and smooth.
I launch OpenRA, it loads the menu, same problem as before (laggy as molasses)
I'm running top, and I can see mono is taking up 102% cpu usage. I let this run for awhile and it does not stabilize.
mono version is: 2.10.5
I do admit, I'm not the biggest fan when it comes to languages that have to run in a virtual machine. Wikipedia sums it up nicely
"Although C# applications are intended to be economical with regard to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language"
Although I want to emphasize that I am not trying to be a jerk here or anything, this is just something to consider. I just want to get this working well, same as you
Is it possible to generate natively compiled executables from c# code?
Posted: Fri Jul 13, 2012 6:42 am
by ddd
foul_owl, C# under mono runs just fine. Did you try recommendations there to diminish CPU+GPU load (except framerate debug patch framerate regulator itself is in the main tree)?
http://www.sleipnirstuff.com/forum/view ... 732#281732
Posted: Fri Jul 13, 2012 7:50 pm
by foul_owl
Are there C# benchmarks I can run independent of the RA codebase to determine if the issue is OpenRA or the mono runtime?
RE:
http://www.sleipnirstuff.com/forum/view ... 732#281732
You mentioned responding to a specific query about battery life, so I was assuming those steps were only with regard to battery life optimization (which I realize now will cut CPU usage, duh!)
So I'll give those steps a try, and report my findings.
Posted: Fri Jul 13, 2012 8:17 pm
by foul_owl
I have followed those steps.
However, I was using the Shellmap as a way to gauge performance in game. (Assuming the Shellmap performance will be similar to in game performance.)
Turning the shellmap off allows the menu to function at a usage framerate, however, with the Shellmap on, it is still laggy, framerate cap or not.
Thank you for your assistance! I am certainly prepared to continue debugging efforts, what do you suggest I try next?
Have you been doing any kind of CPU profiling?
Posted: Fri Jul 13, 2012 8:22 pm
by foul_owl
A further item of note. With framerate cap on and shellmap off, sitting at the menu, top shows that mono is using 68% cpu usage, and the load average sits at around 0.13.
Posted: Sat Jul 14, 2012 7:47 pm
by Matt
See
http://shootout.alioth.debian.org for some benchmark programs and comparisons. You see that C# is a little slower than Java which is a little slower than C.
Maybe have a look at
http://www.mono-project.com/Performance_Tips
Posted: Sun Jul 15, 2012 11:16 pm
by ddd
foul_owl, you can also try OpenRA integrated performance measurement system. It's in the Settings -> Debug -> Show Performance Information.
Posted: Mon Jul 16, 2012 8:22 pm
by foul_owl
Thanks for the help folks!
I am currently trying the OpenRA integrated performance measurement system. (With shellmap on)
It looks like the most cycles are being taken up by render. The green line holds steady at about halfway up the graph (what is the y axis? ms? can we get labels + tics on that?) and occasionally will spike very high (to the top of the OpenRA Main Menu)
What library are you using for rendering?
Posted: Tue Jul 17, 2012 7:53 am
by Matt
It uses the Cg Toolkit or OpenGL via Tao/SDL. You can change this at
https://github.com/OpenRA/OpenRA/wiki/Settings
Posted: Sun Jul 22, 2012 6:17 pm
by Alanim
foul_owl wrote: ↑Thanks for the help folks!
I am currently trying the OpenRA integrated performance measurement system. (With shellmap on)
It looks like the most cycles are being taken up by render. The green line holds steady at about halfway up the graph (what is the y axis? ms? can we get labels + tics on that?) and occasionally will spike very high (to the top of the OpenRA Main Menu)
What library are you using for rendering?
I also had this issue, but I have no idea what exactly caused it.
the problem WILL go away if you create a new profile. I even had the problem go away on my main profile for some odd reason.
To make sure it's the same problem, does the game only slow when you move your mouse? trying clicking and holding it and then moving the mouse, performance shouldn't drop, and clicking rapidly causes massive FPS drops.
Posted: Mon Jul 23, 2012 12:12 am
by chrisf
foul_owl:
On your linux system, could you do `glxinfo | grep renderer` ?