Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my .NET start-up time increase with pre-generated serialization assemblies?

I have a pretty large and complex winforms application. In an effort to reduce the startup time, I pre-generated serialization assemblies using the following batch file.

; delete any existing serialization assemblies
del *XmlSerializers.dll

; gen new serialization assemblies
for %%a in (*.dll) do sgen /assembly:%%a

; delete .deleted files (generated for assemblies which do not allow serialization)
del *.dll.deleted*

However, to my surprise, the startup time actually went up from 4.6 seconds to 6.1 seconds - a jump of 1.5 seconds. This held true whether it was a cold start or warm.

So, questions:

  1. Why does my app start slower with serialization assemblies in place?
  2. Is there a way to see via Perfmon or some other tool when the app is generating serialization assemblies?
  3. Am I generating serialization assemblies correctly?
like image 627
AngryHacker Avatar asked Aug 14 '12 23:08

AngryHacker


1 Answers

You should profile your application to see why startup time is increasing. Perfview will be a good tool to do so.

If too much time is spent in JITtting, consider NGEN your application. If too many pages are loaded, consider using mpgo optimization if you're running under .Net 4.5

like image 52
Feng Yuan Avatar answered Nov 15 '22 14:11

Feng Yuan