r/cpp • • Oct 05 '26

Measuring the Performance of Deterministic Exceptions

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

16 comments sorted by

View all comments

Show parent comment

1

u/jonathanhiggs Oct 06 '26

Stack unwind is remarkably slow. Exceptions need to triggered less than 1 in 1000 time (best case) more likely less than 1 in 5000 times to realise the perf gains of avoiding structured errors, ie they need to be truly exceptional. It essentially makes them a no-go for hot loops

4

u/canadajones68 Oct 07 '26

It is significantly slower than the happy path, but it's still fast on a human scale. I agree that "exceptional" describes their use case well, but I find a lot of people chattering about what qualifies as an exceptional occurrence. I think that if the application can go at least 10 seconds without hitting an exception, so long as you don't spend 10 seconds getting back to what went wrong, you can choose to use exceptions without really thinking about it. Obviously, a hot path is a hot path and you optimise accordingly, but I presume that a competent developer can profile out any exception-induced major bottlenecks rather quickly.