all Technical posts

Application startup performance

Read how a simple configuration setting can impact the startup time of your application dramatically and how to fix this using built-in WCF configuration.

On new environments, Codit always runs benchmark tests to check whether that new environment behaves as expected and to find any anomalies.
This week, these simple tests proved their value yet again:

One of the components of the benchmark test is a simple WCF echo service. A client WCF console application calls this service (also hosted in a console application). The service simply echoes back the request message.

When launching both console applications we experienced extreme delays.
The service host took more than 8 minutes to launch and the client console application took more than 3 minutes to launch.
Because the launch of the console applications typically takes under one second, this demanded for a deeper look.

To get a clearer picture of where the time is lost, I enabled WCF tracing.
This shows that constructing the servicehost and channelfactory takes a lot of time:

Trace when launching the Service

clip_image001

Trace when launching the Client

clip_image002

Digging deeper – and using my favorite search engine – revealed this is probably due to assembly load times.

By default, .NET 3.5 will generate so-called ‘publisher evidence’ for code access security (CAS). Verifying the assembly publishers signature can be very costly, and it is indeed very costly on the new environment.
The generation of this publisher evidence can be disabled: so, let’s disable publisher evidence generation and measure the startup time again after that.

Publisher evidence generation is disabled by adding this Xml snippet to your application configuration file, or to the machine.config file (whatever suits your needs):

<runtime>
<generatePublisherEvidence enabled=”false”/>
</runtime>

After I applied this change, I started my 2 console applications again, and ‘eureka’ they are done in less than one second!

Please note that this change will only apply to .NET 3.5

Trace when launching the Service

clip_image001[6]

Trace when launching the Client

clip_image001[8]

This MSDN link on the generatePublisherEveidence element contains more info about publisher evidence.

The moral of the story is, if you setup a new environment,  test it well!

Peter Borremans

Subscribe to our RSS feed

Thanks, we've sent the link to your inbox

Invalid email address

Submit

Your download should start shortly!

Stay in Touch - Subscribe to Our Newsletter

Keep up to date with industry trends, events and the latest customer stories

Invalid email address

Submit

Great you’re on the list!