Game is slow...C# runtime issues?

Discussion about the game and its default mods.
foul_owl
Posts: 22
Joined: Sat Apr 14, 2012 10:58 pm

Game is slow...C# runtime issues?

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

ddd
Posts: 272
Joined: Sat Oct 23, 2010 5:04 pm

Post 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.
Last edited by ddd on Tue May 01, 2012 2:15 pm, edited 1 time in total.

Matt
Posts: 1144
Joined: Tue May 01, 2012 12:21 pm
Location: Germany

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

foul_owl
Posts: 22
Joined: Sat Apr 14, 2012 10:58 pm

Post 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!

foul_owl
Posts: 22
Joined: Sat Apr 14, 2012 10:58 pm

Post 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?

ddd
Posts: 272
Joined: Sat Oct 23, 2010 5:04 pm

Post 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

foul_owl
Posts: 22
Joined: Sat Apr 14, 2012 10:58 pm

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

foul_owl
Posts: 22
Joined: Sat Apr 14, 2012 10:58 pm

Post 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?

foul_owl
Posts: 22
Joined: Sat Apr 14, 2012 10:58 pm

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

Matt
Posts: 1144
Joined: Tue May 01, 2012 12:21 pm
Location: Germany

Post 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

ddd
Posts: 272
Joined: Sat Oct 23, 2010 5:04 pm

Post by ddd »

foul_owl, you can also try OpenRA integrated performance measurement system. It's in the Settings -> Debug -> Show Performance Information.

foul_owl
Posts: 22
Joined: Sat Apr 14, 2012 10:58 pm

Post 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?

Matt
Posts: 1144
Joined: Tue May 01, 2012 12:21 pm
Location: Germany

Post by Matt »

It uses the Cg Toolkit or OpenGL via Tao/SDL. You can change this at https://github.com/OpenRA/OpenRA/wiki/Settings

Alanim
Posts: 7
Joined: Mon May 14, 2012 12:19 am

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

chrisf
Posts: 246
Joined: Mon Sep 06, 2010 4:59 am

Post by chrisf »

foul_owl:

On your linux system, could you do `glxinfo | grep renderer` ?

Post Reply