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.
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:
### Audio
### Disable all sound processing
SoundVolumeAmbient=0
SoundVolumeFx=0
SoundVolumeMusic=0
Edit #2:
<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.