Board index » delphi » Re: Is there a .NET compiler ?

Re: Is there a .NET compiler ?


2006-03-26 04:12:58 PM
delphi45
Quote
How much of a difference have you found it makes to performance when using
ngen vs. not using it?
It depends on a few things. First, the image must be NGEN'd on the machine
it will execute, not on the development machine, if you want the machine
specific optimizations. Second, ASP.NET does not accept NGEN'd images (the
web application DLL and the assemblies in the /bin directory). This means
that regardless if the image is NGEN'd, ASP.NET will JIT every first time
the web application starts.
Microsoft recommends only components that reside in GAC should be NGEN'd and
only if they will be used/referenced frequently (meaning they are heavily
reused components). Ultimately, it is only the start time that will be
increased and you might be cheating yourself because the JIT during runtime
can still make better decisions even though JIT uses NGEN during runtime.
For .NET 1.1, there was some improvement overall, especially in the services
and utilities area. But for the Web Application, you can not tell the
different on the development computers but during production you notice the
difference. The benefit, once again, is only seen by the first person to
access the functionality.
With .NET 2.0, things change. NGEN is amazing the and the difference is not
only measurable, but noticable as well. Measurable, in my definition,
simply means that a profiler is more likely to report the difference than
the human eye. Noticable means the eye can see the difference.
Quote
Is the difference comparable for all 200+ assemblies or do some benefit
more than others?
Many of the assemblies are less than 200k, so it actually is harder to
notice if your application references only some of them. We have ~200
assemblies, but they are used in different places by different applications,
certianly not all of them are used by one application. When there are fewer
references, you won't notice it. On applications, such as our services and
B2B applications, it is makes a bigger difference. ASP.NET will JIT
(everytime) the web application and the private assemblies. ASP.NET will
only honor the NGEN'd GAC components. When the majority of them are in GAC
and NGEN'd, the only performance difference we notice is the startup time of
the application, beyond that, you won't get any better performance from
NGEN.
.NET 2.0 has a much better NGEN. Combined with setting the assembly base
address for the critical and larger assemblies, startup time flies. You
might want to write a simple program to iterate through all the DLL's
expected to be active during a typical application session (in our case, the
services and web application servers) and locate base addresses that aren't
used frequently. you will have to examine after several reboots to get a
decent sampling. This program should be able to analyze the information and
recommend a good base address. Why? Because noticably, in our case, when
every assembly has to be rebased by Windows it slows the loading down. When
it is properly rebased Windows doesn't have to do anything computationally
during the startup/linking phase.
Quote
Have you found any other advantages to taking this approach?
Just the startup time. For the deployment servers, really doesn't matter.
They are powerful and not frequently rebooted, and very reliable. We
actually started doing this for development boxes and it helps but not
nearly as much as when we do it on the servers. To be honest, the first
time in, you will wait 8 seconds or so on our main web applications or
services, after that, it flies. NGEN'ing cuts it down (on .NET 2.0) to
nearly instant. On 1.x, perhaps about 5 seconds, since the majority if it
is the web app itself and not the dependancies.
Microsoft states that only some of the core .NET assemblies are NGEN'd. I'd
guess that it would be mscoree.dll and perhaps something like system.dll,
system.web.dll, and a few other key ones.
I have not tried this for standalone desktop applications.
You should NGEN, as I said, only on the machine it'll be executed on, not
NGEN'd then deployed. Also, NGEN'ing takes longer than the JIT when not
NGEN'd. So if you deploy an assembly then NGEN while the server is active,
you aren't helping matters unless you reboot later on or something.
Long winded... sorry. The bottom line, we NGEN all our core assemblies,
those that reside in GAC and ignore the private assemblies. The only
benefit is the initial startup time of the service and beyond that NGEN
doesn't make a difference vs. JIT. Properly basing our assembly address
helped significantly better than NGEN did but combining all the techniques
helps alot.
When I earlier said it works well, I am only referring to the startup time
since that is the only aspect of NGEN you can measure. I don't have a
standalone app to test with since I don't write standalone apps, nor do we
have any in our company. Everything is server-based. So things really only
start once in a blue moon. On the dev server boxes and staging servers,
more frequently and yes, NGEN makes a difference. 8 seconds vs 1/2 second
or so for .NET 2.0... and 8 seconds to 5 for .NET 1.x.
Thanks,
Shawn
 
 

Re: Is there a .NET compiler ?

"Shawn B." <XXXX@XXXXX.COM>writes
Quote

Long winded... sorry.
Not at all - that was an excellent description. I am sure I won't be the only
one here to find it useful for future plans. Thank you very much for taking
the time,
 

Re: Is there a .NET compiler ?

"I.P. Nichols" <XXXX@XXXXX.COM>writes
Quote

Me thinks you may be reading tea leaves when you say, "...but such support
is becoming increasingly official, and the technical barriers are almost
entirely solved".

ILMERGE isn't a recent development, IIRC it has been available for almost
three years as a project of Microsoft Research and FAIK it is status hasn't
changed except the current NET 2.0 version is now made available on the
MS Download site while prior versions were only available as a download
for the MS Research site.
Yes - that is true. Previously there was a disclaimer that it was not to be
used in a commercial environment or something like that. If it is ILMerge we
are talking about it would be more accurate to say "... but such support is
now official."
Quote
Precompiling using ngen is also not the norm. It should only be done for
special cases by those who really understand what they are doing - and
that doesn't include me yet."

Thanks to Shawn's excellent post in this thread and the MSDN article "NGen
Revs Up Your Performance with Powerful New Features"
msdn.microsoft.com/msdnmag/issues/05/04/NGen/
I now have a better understanding of what those special cases are.
 

Re: Is there a .NET compiler ?

"Chris Burrows" writes:
Quote
"I.P. Nichols" writes:
>Me thinks you may be reading tea leaves when you say, "...but such
>support is becoming increasingly official, and the technical barriers are
>almost entirely solved".
>
>ILMERGE isn't a recent development, IIRC it has been available for almost
>three years as a project of Microsoft Research and FAIK it is status
>hasn't changed except the current NET 2.0 version is now made available
>on the MS Download site while prior versions were only available as a
>download for the MS Research site.

Yes - that is true. Previously there was a disclaimer that it was not to
be used in a commercial environment or something like that. If it is
ILMerge we are talking about it would be more accurate to say "... but
such support is now official."
As compared to the "official support" of say NGen, ILMERGE isn't supplied as
part of VS.NET 2005 or the latest (Feb 2006) Windows SDK nor is it even
mentioned in the documentation of either. IMO that isn't a good sign that
it's been endorsed with "official support".
However, if you and others want to take the change in it is license agreement
as an indication of "official support" then I will withdraw and be silent!
 

Re: Is there a .NET compiler ?

"I.P. Nichols" <XXXX@XXXXX.COM>writes
Quote

As compared to the "official support" of say NGen, ILMERGE isn't supplied
as part of VS.NET 2005 or the latest (Feb 2006) Windows SDK nor is it
even mentioned in the documentation of either. IMO that isn't a good sign
that it is been endorsed with "official support".

However, if you and others want to take the change in it is license
agreement as an indication of "official support" then I will withdraw and be
silent!

Strange... I thought I was agreeing with you - I must have misunderstood.
The release date was 28 Feb 2006 which could well explain its absence from
VS.NET and the latest (Feb 2006) Windows SDK. Just to clarify - although its
a tool that has its uses, I am still not advocating its use for merging parts
of the framework with apps.
 

Re: Is there a .NET compiler ?

"Chris Burrows" writes:
Quote

Strange... I thought I was agreeing with you - I must have misunderstood.
Sorry 'bout that - my motto is that if anyone on non-tech seems to be
agreeing with me then I have completly misunderstood what they are saying.
;-)