2014-07-11 - gcc's performance bug

recently at work we moved to a newer GCC version. while testing C++11, we've noticed 30% loss in speed, on one of performance-critical components. this happened only when -std=c++11 was enabled. removing this flag regained original performance. this was a blocker for us – we could not afford such a speed loss. one of the colleagues saved they day by digging out simillar performance issue on stack overflow. one more compilation flag makes it all go away.

the problem is that, when the new standard is enabled, makes standard library more complicated. this means a bit more templates, in particular. and yet GCC's heuristics are NOT updated, to be in line with the new code, thus producing way suboptimal code on even the most trivial cases. difference is so huge (100% slower in stackoverflow's example and 30% in our real world scenario) that even move semantics (when in use) cannot compensate for this. this should be noticed and fixed. the fix is so trivial – just rise one heuristic's threshold. and yet the latest gcc 4.9 still does not do that. you just need to know it…

clang does not loose on performance by enabling new standard, btw. in fact, it speeds things up. i wonder when will GCC get up to speed with that as well? or will this share the faith of a long forgotten resource leak, i found recently?

blog/2014/07/11/gcc_s_performance_bug.txt · Last modified: 2014/07/11 09:04 by basz
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0