Bad performance after switching to C++11?!

Recently tool chain in my company (which is called Nokia now – awesome, right?) was update from GCC 4.2 to GCC 4.7. Everybody in my project was very excited – our software will be faster thanks to the move concept and just from standing next to the new compiler! And developers will be able to write lambdas that no one else will be able to decode!

When first performance test results came in I was puzzled – improvement was expected and we got 5-10% performance decrease? I had to ask my overly enthusiastic developers to wait with enriching their code with new shenanigans and I’ve put my detective hat on.
I’ve discovered that the new compiler is not to blame, only adding -std=c++11 makes the difference and shortly after Stackoverflow came with help:
Sufficient to say, default settings of GCC don’t trigger proper inlining of container methods of the STL’s C++11 version. When we increased the -finline-limit the performance got back to level without the -std=c++11 flag. But not a bit higher.

Background: Our project does lot of message handling, uses STL quite heavily and is around 1 milion LOC. We get best results with -O2, yes, even better than with -O3. I have tested various flag combinations and nothing matches regular -O2. But that is for our application and our fast path use pattern. For yours you should always test, test and test for yourself (and investigate!).