Does D use zero-cost exceptions?
Steven Schveighoffer
schveiguy at gmail.com
Tue Apr 16 20:52:57 UTC 2019
On 4/15/19 4:24 PM, Andrei Alexandrescu wrote:
> On 4/15/19 3:36 PM, Nicholas Wilson wrote:
>> On Monday, 15 April 2019 at 19:25:24 UTC, A wrote:
>>> It is well known that exceptions are much slower than their
>>> alternatives, but is there a performance cost for using try/catch,
>>> even when no Exception/Error is being thrown?
>>
>> There is a space cost for the unwind tables, but exceptions are faster
>> than checking error codes all over the place (you do check them right?
>> ;) ).
>
> Sadly that's not quite the case... we've run a bunch of test at Facebook
> back in the day and the sheer presence of unwinding disables a bunch of
> optimizations, notably code motion and everything enabled by it. The
> bottom line effect is quite unpleasant, in the single digits.
It would be important to know what "the day" was. Because there have
been a lot of improvements on LLVM. I wonder if some of this has been
mitigated for LDC at least.
> This is a problem important enough for C++ that they added a keyword
> dedicated to it (noexcept).
Don't we have nothrow for this?
-Steve
More information about the Digitalmars-d
mailing list