Consider this simple code:
using System.Threading.Tasks;
namespace Benchmarks
{
internal static class Program
{
public static void Main(string[] args)
{
TestClassBenchmark().GetAwaiter().GetResult();
}
public static async Task TestClassBenchmark()
{
for (int i = 0; i < 5000; i++)
{
await WorkerNoParameter();
}
}
private static async Task WorkerNoParameter()
{
await NothingWorker();
}
private static Task NothingWorker()
{
return Task.CompletedTask;
}
}
}
Basically a bunch of awaits but everything is really completing synchronously.
That program when run on .NET Core 3.1 allocates the async state machine 5000 times:

Same test run on net462 and netcoreapp2.1 do not allocate at all, which was the expected result.
Hopefully I'm mistaken on this and someone can point me in the right direction, but I thought it was worth running up the flag pole just in case.