rudolfdobias
rudolfdobias

Reputation: 1958

Compiling .NET Core application with CoreRT / another AOT

I'm building an REST API on ASP.NET Core 1.0. In production it'd be IMHO very useful not to use JIT, because the Docker containers with the application are scaling up and down, redeploying during CI over and over, so the just-in-time compilation for every deployed container causes terrible lags, LB health-check deaths and other pains.

As I read, the native compilation with dotnet CLI is discontinued. I tried building with CoreRT, but without luck (details on demand due to complexity).

Since this question is quite abstract, I'm not providing sample codes or detailed information, so for the start there are few questions instead:

  1. Is my presumption correct - will ahead-of-time compilation solve the problem with slow first execution of each path -or - isn't there any other solution anyway?
  2. If it's true, is currently possible to build "native" application (Ubuntu x64 target) from .NET Core?
  3. If it's, what's the best practice - how can I do it? Does anyone has experience with that?

(The target platform would be the ubuntu-14.04-x64 Docker image as well as the compilation platform. For develop purposes would be also nice to compile it on Mac OS X_.)

Upvotes: 14

Views: 7031

Answers (2)

John Chen
John Chen

Reputation: 61

There is a guide for using CrossGen at https://github.com/dotnet/coreclr/blob/master/Documentation/building/crossgen.md. It's a little out of date - I'll see if I can get it updated sometime. The most important part of using CrossGen is to specify the -Platform_Assemblies_Paths switch on the command line, to tell CrossGen the location of all the dependencies that it needs (e.g., System.Private.CoreLib.dll).

Hope that helps. Please let me know if you run into any further issues.

Upvotes: 3

MattWhilden
MattWhilden

Reputation: 1696

Having full native ahead of time compilation isn't possible at this time. It's one of the goals of the CoreRT project linked above but isn't in any state I'd call production ready. The demo at Connect last year should be taken with a pretty big grain of salt. For example they still don't have a reflection subsystem. However, we have a couple of solutions that can greatly reduce the amount of code needing to be generated at JIT time. For .NET Core the tooling is called CrossGen and it's pretty baked these days.

While I have your attention I'll also mention that we're working on an evolution of the NGEN/CrossGen format that alleviates a big chunk of the typical pain involved with typical ni files. That goes under then name ReadyToRun

Hope that helps. Let me know if you have other questions.

Disclosure: I work on the .NET Native runtime and compiler team for UWP (a sister project to CoreRT and LLILC etc)

Upvotes: 8

Related Questions