What are the advantages and disadvantages of pre-jitting assemblies in .NET?
I heard that pre-jitting will improve performance. When should I pre-jit and when shouldn't I pre-jit?
"Pre-jitting" or pre-compiling will improve performance, at start up, because you would be skipping that step. The reason that . NET JITs every time an app and its libraries load is so that it can run on many platforms and architectures with the best possible optimizations without the need for managing your builds.
The JIT compiler is part of the Common Language Runtime (CLR). The CLR manages the execution of all . NET applications. In addition to JIT compilation at runtime, the CLR is also responsible for garbage collection, type safety and for exception handling.
An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (.exe) or dynamic link library (. dll) files, and are the building blocks of . NET applications.
Compiling translates your source code into Microsoft intermediate language (MSIL) and generates the required metadata. Compiling MSIL to native code. At execution time, a just-in-time (JIT) compiler translates the MSIL into native code.
"Pre-jitting" or pre-compiling will improve performance, at start up, because you would be skipping that step. The reason that .NET JITs every time an app and its libraries load is so that it can run on many platforms and architectures with the best possible optimizations without the need for managing your builds.
So you have to weigh whether it's worth the admin headaches to save a few seconds on app start up and library loads. I think the most common use case for doing this is for server installs where you tend to manage few machines and the environment is very stable. E.g. you would not pre-compile for client apps because the target environments are much less predictable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With