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&LTdyn 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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Related news:

News photo

Show HN: Whirlwind – Async concurrent hashmap for Rust

News photo

PropelAuth (YC W22) is hiring Fullstack and Rust engineers

News photo

Rust-Based Redox OS Gets RISC-V Working, Also Now Booting On The Raspberry Pi 4