By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,890 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,890 IT Pros & Developers. It's quick & easy.

CSharp application slow at startup

P: n/a
I've created an application is CSharp. My problem is that it's very
slow to startup the very first time I run it. The second time it's
much faster. Is this normal? Is there anything I can do to boost its
performance?
Thanks.
Andrea
Nov 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
That is normal. NGEN.EXE (shipped with the framework) can help if you
think you need it. Consult .NET tool documentation.

Nov 17 '05 #2

P: n/a
Truong Hong Thi wrote:
That is normal. NGEN.EXE (shipped with the framework) can help if you
think you need it. Consult .NET tool documentation.


That won't address this issue particularly - if the app is much slower
the first time than the second time it's launched, it's almost
certainly just loading the .NET framework itself which is the killer,
rather than the JITting time.

Jon

Nov 17 '05 #3

P: n/a
Then the question is: the app run slowly the very first time it is run
after the computer is turned on, or the very first time after the app
is installed or recompiled on a machine?

I thought Andrea meant the latter; in that case ngen could help.

Nov 17 '05 #4

P: n/a
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Then the question is: the app run slowly the very first time it is run
after the computer is turned on, or the very first time after the app
is installed or recompiled on a machine?

I thought Andrea meant the latter; in that case ngen could help.


If it was the JIT compiler it wouldn't matter if it was the first time it
was run after being reompiled or the 20th. JIT Compilation occurs on every
execution unless there is a native image cached through using NGEN

I agree with Jon it sounds like the issue is that the runtime DLLs are
having to be loaded from disk. The OP could put a small .NET .exe in the
startup folder that "warms up" the machine with by loading the runtime DLLs
off disk. Then Andrea's application won't take that hit.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Nov 17 '05 #5

P: n/a
On Fri, 11 Nov 2005 09:40:58 -0000, "Richard Blewett [DevelopMentor]"
<richard at nospam dotnetconsult dot co dot uk> wrote:
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googleg roups.com...
Then the question is: the app run slowly the very first time it is run
after the computer is turned on, or the very first time after the app
is installed or recompiled on a machine?

I thought Andrea meant the latter; in that case ngen could help.


If it was the JIT compiler it wouldn't matter if it was the first time it
was run after being reompiled or the 20th. JIT Compilation occurs on every
execution unless there is a native image cached through using NGEN

I agree with Jon it sounds like the issue is that the runtime DLLs are
having to be loaded from disk. The OP could put a small .NET .exe in the
startup folder that "warms up" the machine with by loading the runtime DLLs
off disk. Then Andrea's application won't take that hit.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk


In fact my problem is that the application is very slow when I run it
the first time (that can be, for example, after recompiling it). Dows
NGen has drawbacks? I remember reading something about it some time
ago.
Thanks
Andrea
Nov 17 '05 #6

P: n/a
Andrea wrote:
In fact my problem is that the application is very slow when I run it
the first time (that can be, for example, after recompiling it). Dows
NGen has drawbacks? I remember reading something about it some time
ago.
Thanks
Andrea


ngen.exe simply compiles your .exe into native machine code and puts
that code in the cache, so when you execute your .net program again, it
doesn't have to spend time compiling.

I see no downside.
Nov 17 '05 #7

P: n/a
jeremiah johnson wrote:
Andrea wrote:
In fact my problem is that the application is very slow when I run it
the first time (that can be, for example, after recompiling it). Dows
NGen has drawbacks? I remember reading something about it some time
ago.
Thanks
Andrea


ngen.exe simply compiles your .exe into native machine code and puts
that code in the cache, so when you execute your .net program again, it
doesn't have to spend time compiling.

I see no downside.


Downsides:
1) If anything on the system changes (version of framework, processor
etc) the compiled code becomes irrelevant, and will be ignored.
2) NGEN can't perform some of the optimisations that the "normal" JIT
can
3) It's an extra step to perform - added complexity

I'd only consider using it if JITting time was *definitely* an issue
for an application.

Jon

Nov 17 '05 #8

P: n/a
jeremiah johnson wrote:
ngen.exe simply compiles your .exe into native machine code and puts
that code in the cache, so when you execute your .net program again,
it doesn't have to spend time compiling.

I see no downside.


There are lots of downsides. Look up the documentation in MSDN for a
description of the 'brittleness' of native images (read the Remarks
section):

http://msdn.microsoft.com/library/de...torngenexe.asp

Here's a good overview, with a list of the downsides of native images:

http://blogs.msdn.com/jasonz/archive.../24/53574.aspx

Note that the best advice is that you can only tell if native images
will improve your application's performance by actually doing
performance tests. It is not clear from the OP's description if this
would be the case.

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Nov 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.