<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 24 February 2014 07:53, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br></div><div class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
With error - yo get a huge advantage - an _instant_ feedback that it doesn't do<br>
what you want it to do. Otherwise it gets the extra pleasure of running<br>
disassembler to pinpoint your favorite call sites or observing that your<br>
profiler shows the same awful stats.<br>
</blockquote>
<br></div>
My point is you're going to have to look at the asm of the top functions on the profiler stats anyway, or you're wasting your time trying to optimize the code. (Speaking from considerable experience doing that.) There's a heluva lot more to optimizing effectively than inlining, and it takes some back-and-forth tweaking source code and looking at the assembler. I gave some examples of that above.<br>
</blockquote><div><br></div><div>For those interested, in my experience, the value of inlining is rarely related to eliminating the cost of the function call. call and ret have virtually no impact on performance on any architecture I've used.</div>
<div>The main value is that it eliminates stuffing around with parameter lists, and managing save registers. Also, some argument types can't pass in registers, which means they pass through memory, and memory access should be treated no differently from the hard drive in realtime code ;) .. The worst case is a write followed by an immediate read (non-register argument, or save register value); some architectures stall waiting for the full flush before they can read it back. It's called a Load-Hit-Store hazard, and it's the most expensive low level hazard short of an L2 miss.</div>
<div>But the most important use by far is that you can control which functions are leaf functions. Leaf functions (functions that don't allocate a stack frame at all) are critical for good performance. Any small helper functions you call MUST be inlined, or your function is no longer eligible to be a leaf function.</div>
<div><br></div><div>I agree that inline should be a hint (a STRONG hint, not like 'inline' in C, more like __force_inline, perhaps stronger), but I'd like it if I received a warning when it failed for whatever reason. I don't want it to stop compiling, but a nice notification that I should look into it, and the ability to disable/silence the warning if I can't/don't intend to.</div>
</div></div></div>