4 ms·
The Size of Rust Futures
- Matthias247 4y agoI think I might have been the first person who reported this in 2019: https://github.com/rust-lang/rust/issues/59087 https://github.com/rust-lang/rust/issues/59087 It’s a pretty interesting problem. While everyone assumed that futures are lightweight and thereby more efficient than threads, there’s a couple interesting performance gotchas like this one that apply for certain libraries and applications. Due to those I’m still m curious for how many applications the async model is actually a net win or a net loss. Too bad we don’t have time to implement all applications in both ways to gather more data.
- pipologist 4y agoThat’s probably why C++ couroutines allocate by default.
- pornel 4y agoYup, I've ran into this when my entire program ended up being a single massive Future struct, which caused a stack overflow :) I wish there was a Clippy lint for this (https://github.com/rust-lang/rust-clippy/issues/5263 https://github.com/rust-lang/rust-clippy/issues/5263). My current practice is to sprinkle `Box::pin` on code paths that are less common (fallbacks, error handling) or expensive anyway. This cuts down the inlined state considerably without actually causing that many allocations.
- IshKebab 4y agoFeels like the list of Rust async gotchas is quite long. It would be good to see them all in one place.