Does D use zero-cost exceptions?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Apr 15 20:24:27 UTC 2019
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.
This is a problem important enough for C++ that they added a keyword
dedicated to it (noexcept).
More information about the Digitalmars-d
mailing list