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, ¶mPtr, length); std::string p1 = extract_string(parameters, ¶mPtr, length); int32_t p2 = extract_int32(parameters, ¶mPtr, length); uint32_t p3 = extract_uint32(parameters, ¶mPtr, length); tuple<Buffer, size_t, size_t> p4 = extract_blob(parameters, ¶mPtr, 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, ¶mPtr, length); std::string p1 = extract_string(parameters, ¶mPtr, length); array<uint16_t, 3> p2 = extract_vector(parameters, ¶mPtr, length); std::string p3 = extract_string(parameters, ¶mPtr, length); uint8_t p4 = extract_uint8(parameters, ¶mPtr, length); uint8_t p5 = extract_uint8(parameters, ¶mPtr, length); uint64_t p6 = extract_MUID(parameters, ¶mPtr, length); bool p7 = extract_bool(parameters, ¶mPtr, length); tuple<Buffer, size_t, size_t> p8 = extract_blob(parameters, ¶mPtr, length); return self->Match_ResponseLogin(p0, p1, p2, p3, p4, p5, p6, p7, p8); }