Just eliminated C++ exceptions in a complicated multithreaded library. It’s 15% faster despite all performance sensitive functions previously being declared noexcept, with no obvious explanation.
-
-
I don’t think it’s a good “feature” even if it were fast. It makes code hard to understand and forces you to write everything in an “exception-safe” manner which is very hard, almost nobody gets right, and has huge cost. For what, exactly?
-
Let's say you are driving a car and its engine is controlable by software, and suddenly you have an engine failure. Will you let the software crash and automatically stop the car? Or it will handle the exception and notify the driver about the problem and let him take decision?
- 7 more replies
New conversation -
-
-
Note that Rust lets you change panic to abort for this reason, and the library ecosystem is designed such that libraries work without catchable panic enabled.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Exception handling for languages using C++/OS exception handling is expensive, also is expensive (dev time wise) to write your own, though... has been done and could be done again https://github.com/dotnet/coreclr/issues/25167#issuecomment-532757367 …pic.twitter.com/1NyM7isTcW
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I'm not trying to defend the C++ EH model, but here are a few thoughts to consider: 1/n
-
1. Possible explanation for performance delta despite no obvious code generation differences: second-level consequences of instruction cache hits and paging (this is why post-link optimizations are so effective)
- 4 more replies
New conversation -
-
-
I think this is actually good, because they are exceptions. The performance should not matter -- you should take zero exceptions in a frame. That it costs something even when not throwing anything is sad, though.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Really glad to have learned this. Thanks, Tim. Totally changed the way I think about exception handling.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I'm led to believe that ocaml/ML exceptions are cheap.
-
They are, partly (mostly?) because they don't include stack traces by default. Those need to be turned on when starting the application.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.