How can I prevent NGEN from reloading my code (adversely affecting performance)?

I just want to speed up my application on the client side of .NET. I am considering an NGEN code.

Jeffrey Richter wrote this warning about ngening code:

β€’ Poor loading performance (Relocation). When Windows loads NGEND, it checks to download files on its preferred address basis. If the file cannot be downloaded to its preferred base address, then Windows moves the file, corrects all references to the memory address. This is extremely time consuming because Windows needs to load the entire file in memory and modify various bytes inside the file. For more information on rebasing, see my book: Application Programming for Microsoft Windows, 4th Edition (Microsoft Click).

Since I know little about this topic, what should I know before starting to change the settings in my project and what settings should I change?

+1
source share
3 answers

According to this Microsoft blog : β€œThere may be some minor cases where setting base addresses in Vista + is an advantage, but it can be largely ignored.” Thus, using ngen improves startup time, you no longer need to set base addresses if you do not support the OS before Vista. This is a side effect of the new address layout randomization security feature.

+2
source

Moving your DLL files occurs only at boot time, after you have downloaded, there is no more performance due to the move process. Of course, depending on the number and size of the DLL (the number of moves), the load time may be significantly affected, which is a problem, since your application often starts and stops.

Restoring DLL databases to increase loading time requires continuous monitoring and configuration, if you do not leave enough head space between the locations of loading the DLL, as a result, you encounter conflicts as the DLL grows or new DLLs are added to the project.

The following are ways to discuss articles on MSDN to improve application startup time. http://msdn.microsoft.com/en-us/magazine/cc163655.aspx

+2
source

NGEN allows you to specify a base address (also displayed in VS settings). If you are going to NGEN, you basically want to avoid duplication between DLLs. If you have an overlap, the CLR will be forced to reinstall them at boot.

+1
source

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


All Articles