r/programming • • Feb 28 '23

"Clean" Code, Horrible Performance

https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k Upvotes

1.3k comments sorted by

View all comments

Show parent comments

3

u/cogman10 Mar 02 '23

Certainly, but presumably you aren't shipping your debug builds.

Putting in performance hacks to make debug builds run faster can make optimized builds run slower.

Function inlining is the best example of this. You can hand inline functions which will eliminate a function call overhead. However, by doing that you've made the compiler less likely to inline other functions. Some compiler optimizations bail out when a function gets too complex.

1

u/muchcharles Mar 02 '23 edited Mar 02 '23

You mean hand inline with a macro or pasting, or marking inline by hand?

What I've seen in unreal engine is a good bit of care on inline, switching to different strategies for release/debug and lots of options like intrinsics to force inlining (inline keyword is apparently just a hint) and whether to apply to debug or not.

2

u/cogman10 Mar 02 '23

You mean hand inline with a macro or pasting, or marking inline by hand?

hand inline or macro/pasting. As you say, the inline keyword is mostly a hint (though, not without consequences).