"variable tracking" eats compilation time!

I have an automatically generated file that 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, the build time is huge. If I automatically embed all the functions in my respective cases using a script, the build time is halved. GCC 4.5.0 says that ~ 50% of build time is handled by "variable tracking" when I use -ftime-report. What does this mean and how can I speed up compilation while maintaining the excellent locality of the cache for pulling functions from the switch?

EDIT . Interestingly, the assembly time exploded only on debug assemblies in accordance with the following profiling information for the entire project (this is not only the file in question, but still a good metric; this file takes more time):

  • Debugging: 8 minutes 50 seconds
  • Issue: 4 minutes, 25 seconds

If you're interested, here are a few do_func examples, the context is removed. As you can see, I simplified the definition of the problem to show only the relevant parts. If you're interested, all calls to self-> func are calls to boost :: signal.

 static void do_Match_Login(Registry* self, const uint8_t* parameters, uint16_t length) { const uint8_t* paramPtr = parameters; std::string p0 = extract_string(parameters, &paramPtr, length); std::string p1 = extract_string(parameters, &paramPtr, length); int32_t p2 = extract_int32(parameters, &paramPtr, length); uint32_t p3 = extract_uint32(parameters, &paramPtr, length); tuple<Buffer, size_t, size_t> p4 = extract_blob(parameters, &paramPtr, length); return self->Match_Login(p0, p1, p2, p3, p4); } static void do_Match_ResponseLogin(Registry* self, const uint8_t* parameters, uint16_t length) { const uint8_t* paramPtr = parameters; int32_t p0 = extract_int32(parameters, &paramPtr, length); std::string p1 = extract_string(parameters, &paramPtr, length); array<uint16_t, 3> p2 = extract_vector(parameters, &paramPtr, length); std::string p3 = extract_string(parameters, &paramPtr, length); uint8_t p4 = extract_uint8(parameters, &paramPtr, length); uint8_t p5 = extract_uint8(parameters, &paramPtr, length); uint64_t p6 = extract_MUID(parameters, &paramPtr, length); bool p7 = extract_bool(parameters, &paramPtr, length); tuple<Buffer, size_t, size_t> p8 = extract_blob(parameters, &paramPtr, length); return self->Match_ResponseLogin(p0, p1, p2, p3, p4, p5, p6, p7, p8); } 
+6
c ++ optimization gcc
source share
2 answers

You can disable variable tracking. Variable tracking is used to make debugging information a little more valuable, but if this code is auto-generated and you are not going to debug it, then this is not very useful. You can simply disable it for this file only.

 gcc -fno-var-tracking ... 

Gotta do the trick. As I said, I think you can just do this for this file.

+9
source share

In GNU Make, you can turn off variable tracking for one purpose if your compilation team uses the flags variable in type arguments

 fileName.o: CXXFLAGS += -fno-var-tracking 
+1
source share

All Articles