Performance penalty with panic = "unwind"?


#1

Is there a performance penalty to be paid, even during normal execution, when using panic = "unwind" ?


#2

It depends. The best way to test is to benchmark.

panic=unwind does add “landing pads”, which can have various effects. It really just depends.


#3

Unwinding uses the same mechanisms as C++ exceptions, which are designed to run no extra logic unless the code actually panics. There can be some secondary effects – for example, binaries with error handling paths are obviously bigger than code without them – but their impact is typically minimal. As Steve said, benchmark your specific situations.