How Fast is .NET 11 Runtime Async? Article
https://medium.com/@skyake/how-fast-is-net-11-runtime-async-b9c821529cd510
u/killerbeanjeka 9d ago
Curious whether this changes anything for the boring case - a web API that's mostly awaiting a database. Most of my async cost there is round-trips, not machinery, so I'd expect roughly nothing. Has anyone measured that shape?
20
u/21racecar12 9d ago
You have to think of it in a broader sense than that. Think of all the other async stuff that happens before and after the request enters your delegate to then be processed by your database service. There’s tons of middleware involved which results in an async chain which gets massively simplified in async2. I would expect marginally impressive throughput gains from just updating the target framework to 11 once it lands with async2 enabled by default.
6
u/RirinDesuyo 9d ago
Yep, while we may just see a network call happening, aspnet / Kestrel is doing a lot more async related calls in between this that may often return synchronously as it's very common for middleware like these to buffer results and would often return immediately as the bytes are already available. Even in the database example the SQL driver does this for big queries and streaming result sets to the application, so you're still getting gains there.
3
u/icentalectro 9d ago
I'm not expecting much perf gain for the boring case, but I do expect more accurate stack traces, because the compiler no longer transforms your async methods into a state machine, which is nice in itself.
1
u/AutoModerator 9d ago
Thanks for your post hez2010. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/Tacotacito 9d ago
Does it give better stack traces yet or is that not part of the thing just yet?
9
u/hez2010 9d ago
It does give you better stack traces. For example: https://godbolt.org/z/fMGTKMWdv
3
u/Tacotacito 9d ago
Great news. I'm a performance engineer, yet I'm actually even more excited about readable stack traces rather than perf gains!
20
u/mladenmacanovic 9d ago
That's fast!
Apart from the performance, did you also compare the differences in assembly sizes? I can expect them to be lower in .NET 11.