AntonioGanci

Il blog di Antonio Ganci
posts - 201, comments - 420, trackbacks - 31

Ridurre il tempo di startup della propria applicazione con NGen

Sono rimasto favorevolmente colpito dal tempo di startup di SharpDevelop un IDE Open Source per .NET.

Ho visto che il setupkit ad un certo punto esegue l'utility NGen (Native Image Generator). La quale come documentato sulle MSDN migliora le performance in:

  • Native images load faster than MSIL because they eliminate the need for many startup activities, such as JIT compilation and type-safety verification.
  • Native images require a smaller initial working set because there is no need for the JIT compiler.

Inoltre nel file AssemblyInfo.cs dei sorgenti di SharpDevelop hanno inserito i seguenti attributi:

// Use hard-binding for ICSharpCode.SharpDevelop:

[assembly: Dependency("ICSharpCode.Core", LoadHint.Always)]

[assembly: Dependency("ICSharpCode.TextEditor", LoadHint.Always)]

[assembly: Dependency("ICSharpCode.NRefactory", LoadHint.Always)]

[assembly: Dependency("System.Drawing", LoadHint.Always)]

[assembly: Dependency("System.Xml", LoadHint.Always)]

[assembly: Dependency("System.Windows.Forms", LoadHint.Always)]

[assembly: Dependency("WeifenLuo.WinFormsUI.Docking", LoadHint.Always)]

L'attributo Dependency come documentato nelle MSDN:

Indicates when a dependency is to be loaded by the referring assembly.

A dependency that is likely to be loaded Always will cause Ngen.exe to bind to that dependency. Using this hint allows Ngen.exe to generate code that will result in a reduced working set and improved throughput but at the cost of always loading the dependency when the parent assembly is loaded.

Terrò a mente queste cose quando rilascerò la prossima applicazione, anche se non ho ancora misurato il miglioramento rispetto ad un software che non utilizza queste tecniche.

Print | posted on giovedì 14 dicembre 2006 16:21 | Filed Under [ Tips ]

Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET