| ▲ | groundzeros2015 5 hours ago | |||||||||||||||||||||||||||||||
In that sentence I’m referring to the abstract idea of a thread of execution as a model of programming, not OS threads. A green thread implementation could do it too. But what you said about kernel implementation is true. But are we really saying that the primary motivation for async/await is performance? How many programmers would give that answer? How many programs are actually hitting that bottleneck? Doesn’t that buck the trend of every other language development in the past 20 years, emphasizing correctness and expressively over raw performance? | ||||||||||||||||||||||||||||||||
| ▲ | nchie 5 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||
> But are we really saying that the primary motivation for async/await is performance? Of course - what else would it be? The whole async trend started because moving away from each http request spawning (or being bound to) an OS thread gave quite extreme improvements in requests/second metrics, didn't it? | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| ▲ | swiftcoder 5 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
> But are we really saying that the primary motivation for async/await is performance? The original motivation for not using OS threads was indeed performance. Async/await is mostly syntax sugar to fix some of the ergonomic problems of writing continuation-based code (Rust more or less skipped the intermediate "callback hell" with futures that Javascript/Python et al suffered through). | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| ▲ | sureglymop 4 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||
Importantly though, performance might be worse depending on use case and program. Specifically with scheduling in user space it can negatively impact branch prediction as your CPU is already hyper optimized for doing things differently. It's all nuanced and what to choose requires careful evaluation. | ||||||||||||||||||||||||||||||||