3 ms·
For C#, you might want to try a different version with ValueTask instead of Task. It’s more memory-friendly. It would also be interesting to try Native AOT com
by evntdrvn 3y ago
For C#, you might want to try a different version with ValueTask instead of Task. It’s more memory-friendly.
It would also be interesting to try Native AOT compiling both versions…
- noveltyaccount 3y ago+1 to Native AOT, I'd love to see the data. Pretty easy to do, add a line of XML to the csproj and a modified `dotnet publish` command. https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=net7#publish-native-aot-using-the-cli https://learn.microsoft.com/en-us/dotnet/core/deploying/nati...
- neonsunset 3y agoNativeAOT will have negligible impact on memory usage or performance here. JIT performance on average is higher than NAOT.
- noveltyaccount 3y agoYeah and I think NAOT still embeds the same(?) runtime GC into the native binary. So, for memory usage, I would expect it to be nearly/exactly the same.
- cyberax 3y agoJust tried it. No difference whatsoever.
- ygra 3y agoI may remember wrongly here, but wasn't ValueTask merely the go-to option when it's expected that the task would finish synchronously most of the time? I think for the really async case with a state machine you just end up boxing the ValueTask and ending up with pretty much the same allocations as Task, just in a slightly different way.
- evntdrvn 3y agoCheck out this article: https://devblogs.microsoft.com/dotnet/async-valuetask-pooling-in-net-5/ https://devblogs.microsoft.com/dotnet/async-valuetask-poolin...