Would it make sense to use __attribute__ ((noinline)) for functions like _M_realloc_insert?

Groke, Paul paul.groke@dynatrace.com
Fri Aug 21 12:33:44 GMT 2020


Hi,

I've recently noticed that GCC is inlining vector::_M_realloc_insert into some of my functions that call vector::emplace_back. IMO that doesn't make a lot of sense - reallocation is usually so expensive that an extra function call doesn't really matter. And it bloats the code, which has two drawbacks: the binary gets bigger and the fast path gets slower (less efficient pre-fetching/more cache thrashing).

What do you think about marking such functions __attribute__ ((noinline))?

In our own code, we've seen measurable improvements (size & execution speed) by splitting the "slow path" out into helper functions and making those helper functions noinline.

(I've also noticed that there's no __builtin_expect for the fast path, but that's a different topic and IMO far less important.)

Regards,
Paul Groke

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. Dynatrace Austria GmbH (registration number FN 91482h) is a company registered in Linz whose registered office is at 4020 Linz, Austria, Am Fünfundzwanziger Turm 20


More information about the Libstdc++ mailing list