[Scarpet Internals] Disable control flow exceptions from creating stacktraces
altrisi opened this issue ยท 2 comments
I've recently learnt that making exceptions not fill the stacktrace does actually increase performance, it's not just placebo (confirmed by jdk people in a place they use exceptions internally, openjdk/jdk#8072).
Therefore I think we should disable scarpet's control flow exceptions from filling stack traces, given the use of exceptions does seem to make those code paths slower.
The only issue from this: If an exception leaks, we won't know where does it come from. However, scarpet exceptions are not supposed to leak, and we can always remove the code that prevents filling the stacktraces if we need to reproduce a bug with leaking exceptions.
Its definitely a great idea. Change is very simple and scarpet fills its own stacktrace anways (relevant for programmer). I would be very interested how much that would improve typical bad example like an unoptimized add(a, b) -> return(a+b)
. If you don't have time / will to jump on it, I will definitely try to hop in and measure it.
I haven't benchmarked it, a few months ago when I tried without knowing if it would really make a difference there was too much noise around that profile_expr
didn't seem very reliable on my machine (it seemed better, but couldn't be sure), and I wasn't really able to run more proper benchmarks (at the time I didn't use VisualVM, and isolating scarpet code from the rest of the world is anyway really difficult, also for other kinds of profiling like JMH).