Bug 3343 - Problems with profiling
Status: RESOLVED INVALID
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Platform
Version: 1.33 SVN
Hardware: All All
: P3 enhancement
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2007-09-02 18:46 EDT by nixpenguin
Modified: 2007-09-17 01:41:49 EDT
0 users

See Also:



Description nixpenguin 2007-09-02 18:46:43 EDT
Building a profiled, optimized ioQ3 with gcc should be easier (see details below). As it is, there is no profile target, and overriding LDFLAGS on the make command-line is problematic (-ldl and -lm have to be explicitly provided).

Also, after Step 2, not all source files have corresponding '.gcda' files like they do for '.gcno'. In fact, most of them don't, even if I load maps, play online, etc (I'm setting fs_basepath from the build/release-linux-x86_64 folder). As a result, they're compiled with no branch info taken into account. Am I missing something?


Step 1: Build non-optimized for '.gcno'
OPTIMIZE="-O0 -fno-guess-branch-probability -fprofile-generate"
LDFLAGS+="-fprofile-generate"

Step 2: Build optimized for '.gcda'
make clean
OPTIMIZE="[k8, O3, fast math] -fno-guess-branch-probability -fprofile-arcs"
Remove "-fprofile-generate" from LDFLAGS, add "-fprofile-arcs"
Run the resulting binary to generate .gcda files

Step 3: Build final optimized binary
make clean
OPTIMIZE="[above opts] -fno-guess-branch-probability -fprofile-use"
Remove "-fprofile-arcs" from LDFLAGS, add "-fprofile-use"
Comment 1 Tim Angus 2007-09-02 19:23:10 EDT
You don't run gentoo by any chance do you?
Comment 2 nixpenguin 2007-09-02 20:38:03 EDT
Haha, no; I've never used Gentoo. I simply happened to notice that idQ3 1.32c is rather well-optimized, and that it feels more responsive (has lower latency) than the typical ioQ3 build does with some Q3 mods. I'm simply trying to reproduce that feel, because it DOES make a big difference while playing.

Besides, according to the gcc manpage, -funroll-loops is one of the "optimizations generally profitable only with profile feedback available." Which makes me wonder why it's a default optimization, since it certainly does seem detrimental in some cases without that.
Comment 3 nixpenguin 2007-09-03 00:41:09 EDT
> Am I missing something?

Nevermind; I figured it out. Still, it'd be nice if profiling were easier. :)
Comment 4 nixpenguin 2007-09-15 21:46:53 EDT
> [-funroll-loops] does seem detrimental in some cases without [profile feedback].
Or maybe using an overly-optimized OpenAL isn't such a great idea. Oops.


Anyways, regarding profiling:

In order to generate all of the arcs feedback files, I have to attach to ioQ3 with gdb and call __gcov_flush() (an idea found here: http://www.nabble.com/-fprofile-arcs-and-gcov:-data-without-exit()-t396370.html). Shouldn't the game exit cleanly so that this won't be necessary?

Also, I'm trying to compile & link with the -pg flag so that I can profile with gprof (this may help to track down the Intel -march=i686+ problem). That works fine, but once again, the file that is supposed to be generated, gmon.out, is missing. I'm not sure what function to call here, either.
Comment 5 nixpenguin 2007-09-17 01:41:49 EDT
Okay, using exit() instead of _exit() in Sys_Exit solves the problem; gmon.out is now generated. I experience no problems with the usage of exit() on my system, FWIW. o_O