Performance penalty with panic = "unwind"?

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

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.

2 Likes

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.

2 Likes