0

I developed a WinForms application that needs to be working 24 hrs, startup time is slow but that does not matters 'cause possibly only could be ran 1 or 2 times per day with very long periods of execution duration then I'm interested into additional runtime performance and anything of startup performance.

Clarified that, I remembered NGen feature which provides startup beneffits but I've investigated all what I can do and I don't find any useful information about whether NGen also provides runtime performace for my needs.

I only found speculations without a base or any official source, just that, speculations that at least for me are not demonstrated, like this:

Code compiled by NGen runs about 5% slower than JIT-compiled code

http://www.tigranetworks.co.uk/blogs/electricdreams/why-using-ngen-on-your-assemblies-may-not-be-as-smart-as-you-think/

My question is if someone could give me information, details, or if possibly an official source or a performance test about if NGen really adds runtime optimization to an application like mine (24 hrs running and performing runtime operations) or if in the other hand, I should still using JIT for this kind of application.

Any kind of help to clarify my ideas will be appreciated, thanks in advance.

ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
  • 1
    Any optimizations would happen based on your *actual code*. You need to run a profiler against both versions, we can't help with it. – BradleyDotNET Sep 30 '14 at 20:09
  • @BradleyDotNET sorry but I didn't understood your comment, I didn't shown my actual code, but anyways I'm talking generally about an application, I already realized a profiler test of performance and memory. thanks for comment – ElektroStudios Sep 30 '14 at 20:12
  • 2
    NGen doesn't improves runtime performance, rather it improves startup performance. I.e, It avoids the overhead of JIT. It has nothing to do with overall runtime performance. – Sriram Sakthivel Sep 30 '14 at 20:12
  • My point is you had a quote that NGen is 5% slower; that may or may not be true, but it would at least partially depend on *the code itself*. Hence, it will be hard to give an answer. – BradleyDotNET Sep 30 '14 at 20:14
  • @Sriram Sakthivel could you provide official information or something else that explains that?, I really can't understand why is so hard to found a "note" on MSDN or Google specifying this... but I can't find it and I really need to be sure whether it adds or not adds runtime performance. thanks for comment – ElektroStudios Sep 30 '14 at 20:17
  • Personally, I find it hard to believe that an NGen'ed image should run 5 percent slower than its JIT'ed counterpart, but, according to the page you link, the information should have come from Jeffrey Richter, and he usually knows his stuff. I don't happen to own this particular book of his, but it is my clear impression that the main purpose of NGen'ing is to improve startup time. – 500 - Internal Server Error Sep 30 '14 at 20:26
  • 1
    Read [this](http://msdn.microsoft.com/en-us/library/6t9t5wcf%28v=vs.110%29.aspx) completely. From link: *Native images can provide performance improvements in two areas: improved memory use and reduced startup time.* Read *Faster Application Startup* section in provided link. – Sriram Sakthivel Sep 30 '14 at 20:28
  • @500-InternalServerError There's a very good reason for this. NGen shuts down the ability to optimize for specific hardware at runtime. The JIT compiler is one of the key benefits of .NET code. – Zer0 Sep 30 '14 at 20:54
  • @zer0: While this is certainly possible in theory, I was unaware that the JIT'er actually does this now. When asked during a presentation several years ago, the main JIT architect at the time said the reason they didn't optimize for specific CPU models was that the QA effort required was too prohibitive. – 500 - Internal Server Error Sep 30 '14 at 20:57

1 Answers1

2

From the offical NGen page:

Native images can provide performance improvements in two areas: improved memory use and reduced startup time.

and

Performance of native images depends on a number of factors that make analysis difficult, such as code and data access patterns, how many calls are made across module boundaries, and how many dependencies have already been loaded by other applications. The only way to determine whether native images benefit your application is by careful performance measurements in your key deployment scenarios.

You are looking for statements about a runtime performance gain that nobody has promised.

H H
  • 263,252
  • 30
  • 330
  • 514