Have you ever used ngen.exe?

后端 未结 8 1093
感动是毒
感动是毒 2021-01-31 07:40

Has anybody here ever used ngen? Where? why? Was there any performance improvement? when and where does it make sense to use it?

8条回答
  •  囚心锁ツ
    2021-01-31 08:34

    i have used it but just for research purpose. use it ONLY if you are sure about the cpu architecture of your deployment environment (it wont change)

    but let me tell you JIT compilation is not too bad and if you have deployments across multiple cpu environments (for example a windows client application which is updated often) THEN DO NOT USE NGEN. thats coz a valid ngen cache depends upon many attributes. if one of these fail, your assembly falls back to jit again

    JIT is a clear winner in such cases, as it optimizes code on the fly based on the cpu architecture its running on. (for eg it can detect if there are more then 1 cpu)

    and clr is getting better with every release, so in short stick with JIT unless you are dead sure of your deployment environment - even then your performance gains would hardly justify using ngen.exe (probably gains would be in few hundred ms) - imho - its not worth the efforts

    also check this real nice link on this topic - JIT Compilation and Performance - To NGen or Not to NGen?

提交回复
热议问题