Get the latest tech news
Bringing Faster Exceptions to Rust
Three months ago, I wrote about why you might want to use panics for error handling. Even though it’s a catchy title, panics are hardly suited for this goal, even if you try to hack around with macros and libraries. The real star is the unwinding mechanism, which powers panics. This post is the first in a series exploring what unwinding is, how to speed it up, and how it can benefit Rust and C++ programmers.
This function ignores the panic hook and takes a Box<dyn Any + Send> argument instead of an arbitrary format string, which lets us shed some load: While this is just a proof-of-concept (it doesn’t work with nested or greater than 4 KiB exceptions), it indicates the resulting performance: 556.32 ns, or a 1.5% improvement. In the following posts, we’ll explore Itanium and SEH designs, dive into unwinder implementations, and and figure out how to speed up exceptions significantly based on this knowledge.
Or read this on Hacker News