Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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…



+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/nati...


Just tried it. No difference whatsoever.


NativeAOT will have negligible impact on memory usage or performance here. JIT performance on average is higher than NAOT.


Yeah 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.


I 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.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: