1

Due to the JIT compiler in the .net framework, my first calls are slow. To find a solution for this problem I am trying to prejit all my methods which improved my performance. While searching for solutions for the jitting issue, I came out on this SA question: Why subsequent direct method call is much faster than the first call?

I've also found that the .NET Core 3.0 has a aot (ahead of time) compiler. Thus I have created a .NET Core 3.0 project with the code from Why subsequent direct method call is much faster than the first call?, but even though it should use the aot compiler, the first call is still slower.

So my question is: Why do I not see any performance improvements, because I was expecting the first call would also be faster?

1408786user
  • 1,868
  • 1
  • 21
  • 39
  • 1
    .NET Core 3.0 does not have an AOT compiler as such; it has [tiered compilation](https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#tiered-compilation), which is intended to meet some of the same goals but is not full AOT. [CoreRT](https://github.com/dotnet/corert) is the AOT compiler, but this is very much its own thing and not a default. – Jeroen Mostert Oct 17 '19 at 12:55
  • .NET Core also has `Ready to Run`, mentioned directly after `tiered compilation`. That's a form of AOT but not *full* AOT - the AOT compiler doesn't know the capabilities of the machine the code will run on and can't make optimizations that only the JIT compiler can. As the docs say though, this is only avaliable in self-contained apps – Panagiotis Kanavos Oct 18 '19 at 13:55
  • PS: you didn't post what you did to try AOT, although I suspect you just published a program without any modifications. Even if .NET Core had a full AOT compiler, it *wouldn't* use it by default. Check Scott Hansleman's [Making a tiny .NET Core 3.0 entirely self-contained single executable](https://www.hanselman.com/blog/MakingATinyNETCore30EntirelySelfcontainedSingleExecutable.aspx) which shows the settings to use to get a single file with R2R *and* trim unwanted assemblies. – Panagiotis Kanavos Oct 18 '19 at 13:58

0 Answers0