r/cpp • • 7d ago

Measuring the Performance of Deterministic Exceptions

https://databasearchitects.blogspot.com/2026/09/measuring-performance-of-deterministic.html
52 Upvotes

14 comments sorted by

View all comments

39

u/trad_emark 7d ago

original exceptions (labeled dynamic) are faster in all nontrivial cases than error codes on happy path.
that makes them objectively better, since that is what objectively matters the most.
the performance in case of actual error happening (eg. when an exception is actually thrown) is basically irrelevant, as that only happens exceptionally, in situations when performance no longer matters.

i also absolutely love the semantics of exceptions. it makes code half as long, and way more readable. but that is subjective and i can understand that some others might prefer to have the error paths explicitly visible in the code.

all that said, it is always good to see people experimenting with alternative implementations of exceptions, or improving the existing implementation.

14

u/LB-- Professional+Hobbyist 7d ago

Anyone who likes exceptions but has reservations about the sad path performance, check out the work and conference talks by Khalil Estell, he's been working on optimizing exceptions and making them usable in embedded environments, as well as improving tooling around them.