3 ms·
This is an over-simplification. The "fitting in cache" is quite complicated, and as a good rule of thumb exceptions make cache locality less optimal even if you
by jandrewrogers 7y ago
This is an over-simplification. The "fitting in cache" is quite complicated, and as a good rule of thumb exceptions make cache locality less optimal even if you rarely call them. There is little that is "branch-free" about exception code, it literally implies branching.
For performance-sensitive code, I've yet to find a real-world case where exceptions out-perform exception-free code. Nor have I seen much in the way of contrary evidence among people that care about performance.
- lallysingh 7y agoWhat's the complication on the fitting in cache? The error handling is taken out of the code that's loaded in icache. When you throw, a runtime library call is made that walks your stack. Until throw, that code has no reason to be in your icache.