News for hackers. Stuff that matters.
Re:The Performance Impact of C++'s `final` Keyword by usefulcat on Tuesday April 23, 2024 @12:05AM (#40128378)
I find that gcc and clang are so aggressive about inlining that it's usually more effective to tell them what not to inline.

In a moderately-sized codebase I regularly work on, I use __attribute__((noinline)) nearly ten times as often as __attribute__((always_inline)). And I use __attribute__((cold)) even more than noinline.

So yeah, I can kind of see why someone would say inlining is 'evil', though I think it's more accurate to say that it's just not possible for compilers to figure out these kinds of details without copious hints (like PGO).

Re:The Performance Impact of C++'s `final` Keyword by jandrewrogers on Tuesday April 23, 2024 @12:54AM (#40128647)
+1 on the __attribute__((cold)). Compilers so aggressively optimize based on their heuristics that you spend more time telling them that an apparent optimization opportunity is not actually an optimization.

When writing ultra-robust code that has to survive every vaguely plausible contingency in a graceful way, the code is littered with code paths that only exist for astronomically improbable situations. The branch predictor can figure this out but the compiler frequently cannot without explicit instructions to not pollute the i-cache.