📜 ⬆️ ⬇️

CLR and C ++

In a subject of applicability of CLR and C ++ in the big projects working with large volumes of data.


So. When the application code compiled in IL is loaded, the CLR checks for the generation of the NGen.exe generated file with the machine code. With the presence of this file and successful verification of a number of its characteristics, JIT compilation of methods will not be performed and the environment will load compiled methods from this source. What are the disadvantages we have when using NGen files.
1. Perhaps the most basic drawback is the loss of time for modifications to the base address and the application code.
Due to the fact that the product we are making, due to its specifics, it is too gluttonous and seeks, if it is possible, to maximize the memory provided, this problem becomes quite acute. It would be interesting to conduct tests on the modification of base addresses in modules with 60 thousand lines.
2. The NGen utility, due to the lack of some information about the runtime environment, generates averaged code.
But since in C ++ we are confronted in general with the same problem, we will not consider this point in detail.

Now as for the operation of the JIT compiler in the absence of NGen file. When the application method is first accessed, the CLR accesses the specified portion of IL code and performs a Just-In-Time compilation of the method. When compiling, optimization is used depending on the current hardware configuration of the machine. In addition, during compilation, IL-verification of the types used and the methods called is performed. After compilation, the JIT compiler returns to the internal data structure and replaces the address of the method in the IL code with the address of the machine instruction block and transfers control to the code. Now this block will be stored in memory until the program ends and all subsequent calls will be redirected to this block of memory.
')
All this is fine and, ideally, can give very good performance, except in cases when a large number of methods are used in the project and the waiting time during the first run of the algorithm can increase significantly.

Source: https://habr.com/ru/post/74762/


All Articles