Author Topic: Profiling MegaGlest 3.5.3 beta 1  (Read 1492 times)

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Profiling MegaGlest 3.5.3 beta 1
« on: 7 November 2011, 10:33:38 »
As discussed in the headless server thread the headless server is rather stressful on CPU resources already when no player is connected. A web search turns out that the way to profile this is to run valgrind with the callgrind tool, so I did.

Code: [Select]
tomreyn@hisbox:~/SCM/megaglest-trunk/mk/linux$ valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes ./megaglest --headless-server-mode=exit
==10057== Callgrind, a call-graph generating cache profiler
==10057== Copyright (C) 2002-2010, and GNU GPL'd, by Josef Weidendorfer et al.
==10057== Using Valgrind-3.6.1-Debian and LibVEX; rerun with -h for copyright info
==10057== Command: ./megaglest --headless-server-mode=exit
==10057==
==10057== For interactive control, run 'callgrind_control -h'.
Forcing quit after game has compelted [exit]
v3.5.3-beta1-GNUC: 40601 [64bit]-Nov  7 2011 11:06:00, SVN: [Rev: 2791M], [STREFLOP]
Waiting for players to join and start a game...
Headless server is now running...
[2011-11-07 11:13:56] *ERROR* In [/home/tomreyn/SCM/megaglest-trunk/source/glest_game/main/program.cpp::loopWorker 379] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE
[2011-11-07 11:14:02] *ERROR* In [/home/tomreyn/SCM/megaglest-trunk/source/glest_game/main/program.cpp::loopWorker 379] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE
[2011-11-07 11:15:43] *ERROR* In [/home/tomreyn/SCM/megaglest-trunk/source/glest_game/main/program.cpp::loopWorker 379] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE
[2011-11-07 11:20:44] *ERROR* In [/home/tomreyn/SCM/megaglest-trunk/source/glest_game/main/program.cpp::loopWorker 379] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE
quit
server command [quit]

Headless server is about to quit...
terminate called after throwing an instance of 'In [/home/tomreyn/SCM/megaglest-trunk/source/glest_game/main/main.cpp::handleSIGSEGV Line: 644] Error detected: signal 11:
std::runtime_error'
  what():  In [/home/tomreyn/SCM/megaglest-trunk/source/shared_lib/sources/platform/sdl/thread.cpp::~Mutex Line: 117] about to destroy mutex refCount = 1 owner [] deleteownerId []Error saved to logfile [/home/tomreyn/.megaglest/error.log]

==10057==
==10057== Events    : Ir Dr Dw I1mr D1mr D1mw ILmr DLmr DLmw
==10057== Collected : 8772718323 2194997000 1618674464 2674451 4765513 3098528 18268 37651 37768
==10057==
==10057== I   refs:      8,772,718,323
==10057== I1  misses:        2,674,451
==10057== LLi misses:           18,268
==10057== I1  miss rate:           0.3%
==10057== LLi miss rate:           0.0%
==10057==
==10057== D   refs:      3,813,671,464  (2,194,997,000 rd + 1,618,674,464 wr)
==10057== D1  misses:        7,864,041  (    4,765,513 rd +     3,098,528 wr)
==10057== LLd misses:           75,419  (       37,651 rd +        37,768 wr)
==10057== D1  miss rate:           0.2% (          0.2%   +           0.1%  )
==10057== LLd miss rate:           0.0% (          0.0%   +           0.0%  )
==10057==
==10057== LL refs:          10,538,492  (    7,439,964 rd +     3,098,528 wr)
==10057== LL misses:            93,687  (       55,919 rd +        37,768 wr)
==10057== LL miss rate:            0.0% (          0.0%   +           0.0%  )
Killed

Unfortunately the process crashes early. /home/tomreyn/.megaglest/error.log exists but is empty.
Still, we have stats, now I just need to figure out what they mean. ;)

Help is very much appreciated.

Edit:
Reviewing the above it turns out that the game tries to generate or control sound (soundThreadManager->isThreadExecutionLagging). The loopworker should probably not do any sound processing on a headless erver at all. I just added the following to the wiki, hoping it really does as I assume - disable all sound processing:

Code: [Select]
### Audio
### Disable all sound processing
SoundVolumeAmbient=0
SoundVolumeFx=0
SoundVolumeMusic=0

Edit #2:
Quote from: #glest
<weltall> actually tomreyn a better tool is oprofile
<tomreyn> weltall: thanks. can you provide me with a usage?
<tomreyn> that's a valgrind tool?
<weltall> no
<weltall> it's a system wide profiling tool
<weltall> but you can tell it to c heck only for some data
<weltall> needs superuser
<weltall> then you do opcontrol --start
<weltall> do something
<weltall> opcontrol --stop
<weltall> then opreport --symbols pathwherearebinaries
<tomreyn> thanks
<weltall> you might need to collect also the callgraph if it's needed
<weltall> it's just adding -c to both commands but i never got it to work XD]
<weltall> actually tomreyn a better tool is oprofile
<tomreyn> weltall: thanks. can you provide me with a usage?
<tomreyn> that's a valgrind tool?
<weltall> no
<weltall> it's a system wide profiling tool
<weltall> but you can tell it to c heck only for some data
<weltall> needs superuser
<weltall> then you do opcontrol --start
<weltall> do something
<weltall> opcontrol --stop
<weltall> then opreport --symbols pathwherearebinaries
<tomreyn> thanks
<weltall> you might need to collect also the callgraph if it's needed
<weltall> it's just adding -c to both commands but i never got it to work XD

So I'm giving oprofile a try, too.
« Last Edit: 7 November 2011, 16:45:10 by tomreyn »
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Profiling MegaGlest 3.5.3 beta 1
« Reply #1 on: 7 November 2011, 11:07:01 »
running in valgrind is a good thing - I did it a lot when I contributed particle code - but its not a great way to profile.

On ubuntu, you can get the 'perf' tools.  Just type 'perf' at the commandline and it tells you what to do.

then you run "perf record ...."

after that, "perf report".

/Will

badbod

  • Swordman
  • *
  • Posts: 15
    • View Profile
Re: Profiling MegaGlest 3.5.3 beta 1
« Reply #2 on: 9 November 2011, 04:12:59 »
Hi,
   added those audio lines to glestuser.ini but seems no difference in CPU usage.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Re: Profiling MegaGlest 3.5.3 beta 1
« Reply #3 on: 9 November 2011, 22:27:13 »
regarding CPU use in headless mode, i checked in a change to throttle the cpu use which may help so next beta will have that change, in the meantime tomreyn can test cpu usage from svn and give some feedback.

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Profiling MegaGlest 3.5.3 beta 1
« Reply #4 on: 11 November 2011, 00:48:21 »
I dodn't get around to do a proper comparison between the beta and svn head, yet, but my first impression is that svn head requires way less CPU resources. :)
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

treba

  • Guest
Re: Profiling MegaGlest 3.5.3 beta 1
« Reply #5 on: 13 November 2011, 21:57:28 »
we just played a game with 7 cpus of different levels and one human player.

playtime: 37min
max amount of units: 312
units at the end of the game: 243

we got an average of ~15% cpu load
ram went constantly up from 20 to around 250 mb

headless server, svn 2800
running on arch on a vps with singlecore 3ghz qemu cpu and 512mb ram

 

anything