On Tuesday, 28 July 2015 at 21:30:11 UTC, Jonathan M Davis wrote:
On Tuesday, 28 July 2015 at 21:24:31 UTC, David Nadlinger wrote:
On Tuesday, 28 July 2015 at 15:56:52 UTC, Jonathan M Davis wrote:
It[Accepting Booleans]'s far more flexible in generic code.

It's the other way round. pragma(inline) has currently *three* behaviors:

pragma(inline);
pragma(inline, true);
pragma(inline, false);

There is no way to represent those as a single boolean.

The second two states can be. So, you can turn inlining on and off by feeding it a template argument or the result of a function or something. But it is true that you'd be stuck with a static if in the case that you just wanted to set it to the default behavior. I don't know what you'd do to be able to take an argument for all three though - maybe a string or just some known integral value?

I don't know how much it really matters ultimately though, since I expect that for the most part, the folks who are going to be using this pragma won't be using it generically.

Personally, I very much doubt that I'll ever use it, since I've never worked on code that cared about performance so much that you _had_ to force inlining somewhere. The compiler usually does a good enough job (though that's with C++ compilers; who knows how well dmd does).

- Jonathan M Davis

Even for an application that you would assume does a fine job, if you know, via profiling or unittests that a certain expression or method takes a bit of time due to excessive calls, it might just shave off a noticeable amount of time.

Case in point: live dynamic report generation. Let's say we have millions of records from a database and we want to process them and churn out a report. If this is done live, this could easily take minutes depending on the calculations and manipulations you need to do. If a call to a method is made every record, you could easily shave off 10-30 seconds with forcing an inline. And believe me, 10-30 seconds makes a huge difference when you're waiting around for 5+ minutes or more.

There's also time sensitive trading systems that don't want to be half a second slow, due to all that money they want now, now , now.

You'd be surprised how many places you could save a few seconds here or there with a smart inline attribute that the compiler might have missed.

It's been my experience that DMD doesn't really do a good job with this. GDC is much much better, but DMD truly lacks luster with inlining.

Reply via email to