News for hackers. Stuff that matters.
Re:Forced Inlining Might Be Slow by halayli on Monday October 09, 2017 @12:49PM (#15435418)
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.
Re:Forced Inlining Might Be Slow by smitherfield on Monday October 09, 2017 @02:54PM (#15436448)
True, 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).
Re:Forced Inlining Might Be Slow by rurban on Monday October 09, 2017 @07:21PM (#15438208)
No, 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.
Re:Forced Inlining Might Be Slow by Narishma on Monday October 09, 2017 @02:01PM (#15436027)
The main benefit of inlining come from the additional optimizations it allows the compiler to do.
Re:Forced Inlining Might Be Slow by loeg on Monday October 09, 2017 @02:45PM (#15436380)
That is not a benefit of forced inlining (over allowing the compiler to decide what to inline).
Re:Forced Inlining Might Be Slow by webkike on Monday October 09, 2017 @01:18PM (#15435645)
It's a trade-off. Sometimes simply calling a function will flush the I cache
Re:Forced Inlining Might Be Slow by CrystalGamma on Monday October 09, 2017 @01:45PM (#15435877)
Also, there are function prologues/epilogues and sometimes additional instructions to satisfy the calling convention.
Re:Forced Inlining Might Be Slow by webkike on Monday October 09, 2017 @04:45PM (#15437318)
True, 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.