Have you ever used ngen.exe?

后端 未结 8 1130
感动是毒
感动是毒 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:09

    Yes. Used on a WPF application to speed up startup time. Startup time went from 9 seconds to 5 seconds. Read about it in my blog :

    I recently discovered how great NGEN can be for performance. The application I currently work on has a data access layer (DAL) that is generated. The database schema is quite large, and we also generate some of the data (list of values) directly into the DAL. Result: many classes with many fields, and many methods. JIT overhead often showed up when profiling the application, but after a search on JIT compiling and NGEN I though it wasn’t worth it. Install-time overhead, with management my major concern, made me ignore the signs and focus on adding more functionality to the application instead. When we changed architecture to “Any CPU” running on 64 bit machines things got worse: We experienced hang in our application for up to 10 seconds on a single statement, with the profiler showing only JIT overhead on the problem-area. NGEN solved the problem: the statement went from 10 seconds to 1 millisecond. This statement was not part of the startup-procedure, so I was eager to find out what NGEN’ing the whole application could do to the startup time. It went from 8 seconds to 3.5 seconds.

    Conclusion: I really recommend giving NGEN a try on your application!

提交回复
热议问题