5 ms·
aside from compilation time, inlining doesn’t mean your program will run faster, because now you’re filling your icache with the inlined instructions rather tha
by halayli 9y ago
aside from compilation time, inlining doesn’t mean your program will run faster, because now you’re filling your icache with the inlined instructions rather than a call instruction, that might be flushed away on a missed branch prediction.
- webkike 9y agoIt's a trade-off. Sometimes simply calling a function will flush the I cache
- CrystalGamma 9y agoAlso, there are function prologues/epilogues and sometimes additional instructions to satisfy the calling convention.
- webkike 9y agoTrue, and the functions in which inlining is most effective are small non recursive functions that don't lose any debug info from omitting the frame pointer.
- Narishma 9y agoThe main benefit of inlining come from the additional optimizations it allows the compiler to do.
- loeg 9y agoThat is not a benefit of forced inlining (over allowing the compiler to decide what to inline).
- smitherfield 9y agoTrue, but less so now than a decade ago; if it's a hot path (which anything `__forceinline` presumably is, assuming the author has a reasonable understanding of optimization) inlining is usually going to be a performance win, and often a cache/code size win as well (optimizing the inlined code, avoiding register spills).
- rurban 9y agoNo, still. If it's an unlikely branch and pretty big, better put it into an extra function call if possible. icache pollution is still an issue.