"variable tracking" is eating my compile time!
- by wowus
I have an auto-generated file which looks something like this...
static void do_SomeFunc1(void* parameter)
{
// Do stuff.
}
// Continues on for another 4000 functions...
void dispatch(int id, void* parameter)
{
switch(id)
{
case ::SomeClass1::id: return do_SomeFunc1(parameter);
case ::SomeClass2::id: return do_SomeFunc2(parameter);
// This continues for the next 4000 cases...
}
}
When I build it like this, the build time is enormous. If I inline all the functions automagically into their respective cases using my script, the build time is cut in half. GCC 4.5.0 says ~50% of the build time is being taken up by "variable tracking" when I use -ftime-report. What does this mean and how can I speed compilation while still maintaining the superior cache locality of pulling out the functions from the switch?
EDIT: Interestingly enough, the build time has exploded only on debug builds, as per the following profiling information of the whole project (which isn't just the file in question, but still a good metric; the file in question takes the most time to build):
Debug: 8 minutes 50 seconds
Release: 4 minutes, 25 seconds