For instance, Max Hoffman and Raphael Poss separately report impressive speedups (on the happy path of their programme, at least) thanks to [using panic/recover]. Explanations range from a decreased need for intermediate function results and code that is comparatively friendlier to the CPU’s branch predictor.
Reminds me of a talk I’ve seen by an embedded C++ developer who found that, contrary to what he’d been told, using exceptions resulted in smaller/faster binaries. There is significant overhead in having to return errors and then check for errors at every function-call boundary — it’s small at each call site, but it adds up.
If you’re using exceptions for control flow, then exceptions really might be slow. Based on relatively little data, this seems more common in Java (like for iterators), probably for some weird historical reason, maybe everyone was so excited to have structured errors that they went overboard?
Well, this is OT, but in C++ using exceptions adds a bunch of tables to the binary that are used by the runtime code to locate destructors and “catch” blocks to call while unwinding the stack. Folklore is that these bloat the binary size. The lesson is that they do add some size, but often less so than all the extra code to do manual error handling.
Also OT, but Python explicitly does use exceptions for flow control: the way an Iterator signals it’s reached its end is to throw a particular exception.
Reminds me of a talk I’ve seen by an embedded C++ developer who found that, contrary to what he’d been told, using exceptions resulted in smaller/faster binaries. There is significant overhead in having to return errors and then check for errors at every function-call boundary — it’s small at each call site, but it adds up.
If you’re using exceptions for control flow, then exceptions really might be slow. Based on relatively little data, this seems more common in Java (like for iterators), probably for some weird historical reason, maybe everyone was so excited to have structured errors that they went overboard?
Well, this is OT, but in C++ using exceptions adds a bunch of tables to the binary that are used by the runtime code to locate destructors and “catch” blocks to call while unwinding the stack. Folklore is that these bloat the binary size. The lesson is that they do add some size, but often less so than all the extra code to do manual error handling.
Also OT, but Python explicitly does use exceptions for flow control: the way an Iterator signals it’s reached its end is to throw a particular exception.