472,102 Members | 1,056 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

URGENT: Please Help: .Net dll compilation time

MR
Hi,
it has been observed that when we try to instantiate
a .Net dll for the first time in a session (e.g. from an
exe in .Net), it takes almost 10 times compared to
subsequent instantiations.

We have A.exe, developed in VB.Net, where, in a button
click, we are instantiating the Test.dll also developed in
VB.Net. We run three instances of A.exe simultaneously
(say A1, A2 and A3 are the three instances). Clicking on
the button in A1, A2 and A3 for the first time, it takes
almost 2000 miliseconds to instantiate the dll in each
instance (A1, A2, A3). Clicking the second time onwards,
the time for instantiation reduces to 130 miliseconds.

My questions are:
1. As I understand a dll can take more time in the first
instantiation. But why is it taking more time in the first
click from each of the exe instances instead of just the
very first click from A1? Why is it session/connection
dependent?

2. Is there any way we can ensure that the dll
instantiates in the fastest possible time in the very
first try?

It would great if someone can please help.

Thanks,
M.R.

Nov 20 '05 #1
1 2123
Hi MR,

.Net is a Just in time compiled platform so the first click on a button it
takes time to compile all the methods that are being called by that click
but each subsequent click is fast because .Net doesn't need to compile that
code again. The reason you are seeing this per-instance rather than system
wide is that the a .Net assembly (dll or exe) is loaded in to each process
independently. Each process creates what is called an AppDomain (a process
contains at least one default domain but can contain more) that contains
the assemblies loaded for that program.

As far as beating this performance hit, we have a utility that ships with
the .Net framework called ngen.exe. ngen performs the Just in Time compile
step in advance and saves the native code image created to a system cache
where it can be used for speedier execution. If you run the ngen utility on
your assemblies then run them, you should see an increase in performance.
In fact, this is one of Microsoft's recomended performance enhancements.

For more information about writing performant managed code, check out:

http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/highperfmanagedapps.asp?frame=true

For more information about ngen, check out:

http://msdn.microsoft.com/library/de...us/cptools/htm
l/cpgrfnativeimagegeneratorngenexe.asp

--
Michal Sampson VB .Net Deployment Developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
--------------------
Content-Class: urn:content-classes:message
From: "MR" <mo**********@hotmail.com>
Sender: "MR" <mo**********@hotmail.com>
Subject: URGENT: Please Help: .Net dll compilation time
Date: Thu, 25 Sep 2003 13:04:47 -0700
Lines: 31
Message-ID: <0b****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcODoETjwP8TKDAkSeSwsDLfpu2aaw==
Newsgroups: microsoft.public.dotnet.languages.vb
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:141310
NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,
it has been observed that when we try to instantiate
a .Net dll for the first time in a session (e.g. from an
exe in .Net), it takes almost 10 times compared to
subsequent instantiations.

We have A.exe, developed in VB.Net, where, in a button
click, we are instantiating the Test.dll also developed in
VB.Net. We run three instances of A.exe simultaneously
(say A1, A2 and A3 are the three instances). Clicking on
the button in A1, A2 and A3 for the first time, it takes
almost 2000 miliseconds to instantiate the dll in each
instance (A1, A2, A3). Clicking the second time onwards,
the time for instantiation reduces to 130 miliseconds.

My questions are:
1. As I understand a dll can take more time in the first
instantiation. But why is it taking more time in the first
click from each of the exe instances instead of just the
very first click from A1? Why is it session/connection
dependent?

2. Is there any way we can ensure that the dll
instantiates in the fastest possible time in the very
first try?

It would great if someone can please help.

Thanks,
M.R.


Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jie | last post: by
7 posts views Thread by Gordon Smith | last post: by
8 posts views Thread by Chris | last post: by
17 posts views Thread by Saps | last post: by
reply views Thread by Vish | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.