greencopper wrote:Also is there a way to debug the code while running the server part to determine bottlenecks if any? I have done optimization on other languages, but not on C++. In this case I am talking about run-time debugging displaying function/method calls etc.
Here is one of my tests (I have a few but this is a nice simple one)
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
valgrind --tool=callgrind --instr-atstart=no --dump-instr=yes --collect-jumps=yes \
/home/zeno/minetest/bin/minetestserver \
--config ~/.minetest/disk_test.conf --world ~/.minetest/worlds/disk_test
I use the
--instr-atstart = no switch so that I can start the profiling when I want (after all the init stuff usually). If you want to capture data for the entire execution, simply omit the switch (or change it to
--instr-atstart = yes).
Note that, for callgrind, you should build the
release build of minetest server but
add the -g switch to the gcc/clang options. I.e. callgrind is really designed for collecting data for programs that have been built
with optimisation.
Omit the callgrind_control commands below if you don't use the
--instr-atstart=no switch
After
minetestserver is running, to start collecting data (start instrumentation), run
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
To turn it off
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
The data will be dumped in the directory you run valgrind from with the filename
callgrind.out.PIDYou can certainly (try to) read that file but not many people would get very far. I use KCachegrind to visualise the collected data.
There is a lot you can do with callgrind (including separating the data by thread)... best to start here:
http://valgrind.org/docs/manual/cl-manual.html for stuff more advanced than the example I gave at the top of this post.
Edit: You don't
need to add the -g switch to the compiler options but it's very beneficial; with it added you can look at the cost of things inside functions so you get a lot more detail.