5 ms·
massive PSA dotnet rely a lot on the JIT to optimize code So cases when you run your program once (middleware, short lived servers) the performance is abysmal
by Shadonototro 6y ago
massive PSA
dotnet rely a lot on the JIT to optimize code
So cases when you run your program once (middleware, short lived servers) the performance is abysmal
Never trust "ultra optimized & cheated" benchmarks where they run the same code 1_000_000_000 times
And the time/resources it takes to reach steady state is also something to keep in mind, warming up the JIT isn't free
Hence the reason why most people looked at Go as an alternative to both dotnet/Java/Scala
- pjmlp 6y agoWhich is ironic given that current Go compilers still generate slower code, and lack the GC knobs for performance tuning.
- gameswithgo 6y ago* Do you have any hard data to back up the abysmal claim? Like a couple of short lived program benchmarks? * You can AOT compile .NET, that has been true for a while but now it is a first class option
- Shadonototro 6y agoRun any benchmark, and compare 1 execution vs 1_000_000_000 It's been a while i haven't used dotnet, but just take any available benchmark, and compare default results with UnrollFactor = 1 IterationCount = 1 WarmupCount = 0 There are probably more options, but i forgot them https://benchmarkdotnet.org/articles/configs/jobs.html#run https://benchmarkdotnet.org/articles/configs/jobs.html#run > You can AOT compile .NET, that has been true for a while but now it is a first class option That's not true at all, if you refer to R2R, it's only partial, your code is still JIT'd at runtime, it only helps to speedup a little bit the cold startup time AOT compilation? I'll believe it when they'll release it, until then, it's all speculation
- csharptwdec19 6y ago> AOT compilation? I'll believe it when they'll release it, until then, it's all speculation Devil's in the details, but there -is- AOT compilation[0]. While it hasn't been released as an official product, it has been used for a few projects including a commercial game [1]. And yes, they're looking into the next steps to make it a 'released' thing.[2] [0] - https://github.com/dotnet/corert/ https://github.com/dotnet/corert/ [1] - https://github.com/dotnet/corert/issues/8233#issuecomment-659454920 https://github.com/dotnet/corert/issues/8233#issuecomment-65... [2] - https://github.com/dotnet/runtimelab/tree/feature/NativeAOT https://github.com/dotnet/runtimelab/tree/feature/NativeAOT
- Shadonototro 6y agoAs mentioned by someone above >This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo. Talented people are working on CoreRT, sadly it doesn't seems to be the focus of the product manager, hence my concerns
- holtalanm 6y ago> dotnet rely a lot on the JIT to optimize code .NET has had AoT compilation since v1. What, exactly, are you talking about? Sure, rely on JIT for stuff like webapps and the like, but a CLI tool that is designed to run once would be a good candidate for AoT compilation, which, as I stated before, .NET supports.
- anon_tor_12345 6y agoWhat does AOT have to do with benchmarks that don't use AOT and report great performance? Also you're dramatically overstating how mature AOT is for dotnet https://github.com/dotnet/runtimelab/tree/feature/NativeAOT https://github.com/dotnet/runtimelab/tree/feature/NativeAOT >This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
- nvrspyx 6y agoI don't have much experience with .NET, but I believe the current production AOT option is the ReadyToRun publish option[1], which is actually a combination of AOT and JIT. The repo you linked is their work on a complete, native AOT implementation. [1]: https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run https://docs.microsoft.com/en-us/dotnet/core/deploying/ready...
- anon_tor_12345 6y agoI'm getting downvoted but either people don't understand the difference between R2R and AOT (or they're just pissy today); from your link >R2R binaries improve startup performance by reducing the amount of work the just-in-time (JIT) compiler needs to do as your application loads. and >However, R2R binaries are larger because they contain both intermediate language (IL) code, which is still needed for some scenarios and >Ahead-of-time generated code is not as highly optimized as code produced by the JIT. To address this issue, tiered compilation will replace commonly used ReadyToRun methods with JIT-generated methods.
- nick_ 6y agoMost would make that trade-off 10/10 times they're conscious of the choice.
- Someone1234 6y agongen has existed since .Net 2.0, as has the GAC. So if you're targeting .Net 1.0 this "PSA" is impactful, otherwise, it isn't really accurate. It could hypothetically apply if you created a new .Net process each execution (thus invalidating the GAC) but even then you could just add ngen to your build/deployment process.
- fabian2k 6y agoThere are situations where startup overhead matters, and in those cases dotnet is not a good fit at this moment. But there are a lot of areas where it doesn't matter and those are where dotnet and Java are typically used. Running the same code a lot is certainly not cheating, a lot of code where performance really matters is actually doing the same thing over and over. .NET 5 added source generators, which are one part that is necessary to get to a point where ahead of time compilation would be feasible for typical .NET projects. So this is an aspect that Microsoft seems to be looking into now.
- MarkSweep 6y agoAdding on to this, the work done to make .NET linker friendly will also help make it more amenable to AOT. For people who have not been following .NET closely, there is a thing called Blazor that runs in the browser using web assembly. To get the download size down, a linker is used to remove classes and methods that are not being used. You can also use this when deploying other types of apps. https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/configure-linker https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and...
- kaba0 6y agoBecause the large majority of programs run for less than a second? Also, who is that most people? Go is a tiny language compared to Java and C#.
- loic-sharma 6y agoYour comment is half right. While your app is JIT compiled, the runtime and its libraries are AOT compiled using a technology called cross-gen. As others have pointed out, the .NET team has a NativeAOT experiment (previously called CoreRT) that lets you AOT compile your entire app. Also, Java takes longer to reach steady state as it starts execution in an interpreter, then JIT compiles hot methods. .NET skips the interpreter and goes straight to JIT compilation.
- benaadams 6y agoSpecify the platform and that you want it precompiled for that platoform? https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#readytorun-images https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotne... <RuntimeIdentifier>linux-x64</RuntimeIdentifier> <PublishReadyToRun>true</PublishReadyToRun> It will still Jit after 30 calls to refine further; but should start at a higher level of optimization.