On Thu, 20 Feb 2014 21:05:29 GMT, Dicebot wrote:

On Thu, 20 Feb 2014 19:08:46 +0100, Sönke Ludwig wrote:

I definitely think that 2) is the absolute minimum that has to be done
(it would probably even be enough to resolve symbols for the stack trace
lazily). And probably when that is done, there isn't even a real problem
anymore (the 404 case should still be changed).

No, it won't be enough, I have made some quick tests with hacked changed druntime. You will never ever be able to use exceptions efficiently if those are allocated (especially if it is GC allocation that can trigger collection). It may not be notable if normal processing code also allocates regularly but than it does not make any sense to speak about performance at all.

Note that my experiments (in the thread linked in the first post) indicate that it is not the allocation itself that's expensive. Exceptions are slow only the first time they are thrown; there must be something that gets cached in the exception that greatly speeds them up on subsequent throws.

Maybe now that this [1] is merged, I can try again whether it makes any difference.

But maybe someone could also answer the question whether it is actually safe to reuse exceptions. The fact that the runtime caches things in them indicates that there could be a problem, at least if they are thrown from different locations.

[1] https://github.com/D-Programming-Language/druntime/pull/717