473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

JIT compilation question

Hello,

I posted this as a follow-on question yesterday, but nobody has bitten:

Is a .Net application recompiled (i.e. from CIL to native code) each time it
is run? Or is the native code cached - and if so, where? Thanks.
Nov 15 '05 #1
11 2553
It is compiled only once, then it is stored in the native assembly cache,
or something.
You can precompile it yourself too with ngen.exe
But it gets a little more complicated.
The whole application isn't compiled until the parts are needed, so the
initial startup time will be fast enough, but you may encounter slowdowns
the first time you do new stuff, like getting a new exception.

--
The hotmail account will most likely not be read, so please respond only
to the news group.
Nov 15 '05 #2
Each method is JIT compiled when called for the first time, the JIT'd code
is NOT persisted, it's simply cached in memory and remains there until the
program ends (application domain unloads).

Willy.

"Sheila Jones" <sh**********@btopenworld.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hello,

I posted this as a follow-on question yesterday, but nobody has bitten:

Is a .Net application recompiled (i.e. from CIL to native code) each time
it
is run? Or is the native code cached - and if so, where? Thanks.

Nov 15 '05 #3
Thanks for the reply. I knew about methods only being compiled the first
time they are called, I just didn't know whether the CLR forgot everything
it had compiled when the application terminated. You say it stores the
native code.

I suppose the follow-on question is: how does the CLR know that the cached
native code is still valid and that, for example, the .exe hasn't been
replaced with an updated version?
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:op**************@msnews.microsoft.com...
It is compiled only once, then it is stored in the native assembly cache,
or something.
You can precompile it yourself too with ngen.exe
But it gets a little more complicated.
The whole application isn't compiled until the parts are needed, so the
initial startup time will be fast enough, but you may encounter slowdowns
the first time you do new stuff, like getting a new exception.

--
The hotmail account will most likely not be read, so please respond only
to the news group.

Nov 15 '05 #4
So you are saying that a CLR program is re-JITted each time it is run? Why
isn't the native code cached?
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
Each method is JIT compiled when called for the first time, the JIT'd code
is NOT persisted, it's simply cached in memory and remains there until the
program ends (application domain unloads).

Willy.

"Sheila Jones" <sh**********@btopenworld.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hello,

I posted this as a follow-on question yesterday, but nobody has bitten:

Is a .Net application recompiled (i.e. from CIL to native code) each time it
is run? Or is the native code cached - and if so, where? Thanks.


Nov 15 '05 #5
n!
> So you are saying that a CLR program is re-JITted each time it is run? Why
isn't the native code cached?


As I understand it, if the native code were cached, then the CLR would be
unable to validate it the next time its run. Basically for security reasons.

n!
Nov 15 '05 #6
>I suppose the follow-on question is: how does the CLR
know that the cached
native code is still valid and that, for example, the .exe hasn't beenreplaced with an updated version?


Hi,

Each time an assembly is compiled it is assigned an
internal MVID {Module Version Identifier}. The MVID is
seperate and unrelated to any "user friendly" versioning
schemes; it exists specifically so that the CLR can know
if an assembly's contents and/or public contracts have
changed since the last time it was JIT-ed.

When the CLR attempts to load a cached pre-compiled
module's native image the native image's MVID is compared
to the MVID in the deployed assembly, and if necessary the
code is re-JIT-ed. Note that the compiled native image
stores the MVID of the target module AND MVIDS OF ALL
MODULES THE TARGET DEPENDS ON - so a change to any
dependancy can trigger a recompilation of a whole bunch of
stuff...

--Richard

Nov 15 '05 #7
-----Original Message-----
Each method is JIT compiled when called for the first time, the JIT'd codeis NOT persisted, it's simply cached in memory and remains there until theprogram ends (application domain unloads).

Willy.


Uhhm, this is not correct according to "Essential .NET
Volume 1" {Don Box, Chris Sells} pages 153-157. Please
refer to my other reply in this question thread for a
synopsis of the Don Box answer to this question...

--Richard

Nov 15 '05 #8
Richard,

Am I? I was only replying to OP's question which did not mentioned running
pre-jitted code (NGEN).

<Is a .Net application recompiled (i.e. from CIL to native code) each time
it
is run? Or is the native code cached - and if so, where? Thanks.>

Willy.
"Richard" <an*******@discussions.microsoft.com> wrote in message
news:ee****************************@phx.gbl...
-----Original Message-----
Each method is JIT compiled when called for the first

time, the JIT'd code
is NOT persisted, it's simply cached in memory and

remains there until the
program ends (application domain unloads).

Willy.


Uhhm, this is not correct according to "Essential .NET
Volume 1" {Don Box, Chris Sells} pages 153-157. Please
refer to my other reply in this question thread for a
synopsis of the Don Box answer to this question...

--Richard

Nov 15 '05 #9
By default, the JIT happens every time, but it only happens for the
functions that are called. There's a tradeoff between the time it takes the
JIT to run and the time and overhead of opening another file and reading it
into memory. There's also the issue of tracking the environment (security,
etc.) of the method when it was JITted, and then comparing that with the
environment of the current program.

There is a tool named NGEN that can "pre-jit" an entire assembly for you as
a load optimization, and some of the BCL assemblies have that done. That
pre-jitted cache is only valid for the same environment, but the check is
done on a per-user basis. There is also another level of indirection in the
NGEN case, and the resulting code may be slightly less optimal.

Doing this on a per-function basis would be really complex.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://weblogs.asp.net/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
"Sheila Jones" <sh**********@btopenworld.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hello,

I posted this as a follow-on question yesterday, but nobody has bitten:

Is a .Net application recompiled (i.e. from CIL to native code) each time it is run? Or is the native code cached - and if so, where? Thanks.

Nov 15 '05 #10
Richard,

I'm fairly sure that Don and Chris are talking about the NGEN case, not the
normal case.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://weblogs.asp.net/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
"Richard" <an*******@discussions.microsoft.com> wrote in message
news:ee****************************@phx.gbl...
-----Original Message-----
Each method is JIT compiled when called for the first

time, the JIT'd code
is NOT persisted, it's simply cached in memory and

remains there until the
program ends (application domain unloads).

Willy.


Uhhm, this is not correct according to "Essential .NET
Volume 1" {Don Box, Chris Sells} pages 153-157. Please
refer to my other reply in this question thread for a
synopsis of the Don Box answer to this question...

--Richard

Nov 15 '05 #11
Eric Gunnerson [MS] <er****@online.microsoft.com> wrote:
I'm fairly sure that Don and Chris are talking about the NGEN case, not the
normal case.


I've just checked in the book, and indeed they are.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Novice | last post by:
Hi all, I'm afraid this is the second posting of this information as I didn't get a response on the previous post. I will try to shorten my message (i.e. be more concise) in the hopes that it will...
11
by: Michael Gaab | last post by:
Compilation in c generally has four phases 1. Preprocessing 2. Compilation 3. Assembly 4. Linking. If I use a flag that will not link the code, order of compilation is not an issue,...
5
by: Rob | last post by:
By default, the web.config file of an ASP.NET application contains the following debug attribute for the compilation element: <compilation debug="true"/> My question is this: When doing the...
6
by: alban | last post by:
Hello I have got some problems of compilation on a AIX IBM, I use the XLC compilator (And I can't install another one). I try to compile code Pro*c ".pc" (oracle), I need do a pre-compilation...
10
by: Dave | last post by:
I'm a C++ programmer of many years, trying to get my feet wet in C#. I have a question about conditional compilation. In C++, I would sometimes define a constant in an include file, and then...
2
by: tkirankumar | last post by:
Hi all, uname -a SunOS cbmrsd1a1 5.10 Generic_118833-17 sun4us sparc FJSV,GPUZC-M g++ -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/specs Configured with:...
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
9
by: Raxit | last post by:
Hi, we are designing some stuff , that will generate c++ program(s) What we want is we wanted to execute that generated code.... i.e. 1. Xml based language 2. C++ code generated from 1....
3
by: Ashik | last post by:
I have a simple compilation question, but I haven't been able to find an answer for it anywhere online. I've made a simplified version of my problem using a few files. The main problem is that...
8
by: Marc | last post by:
I am studying ASP.NET and have a simple question reading the first lines in this page: http://msdn.microsoft.com/en-us/library/ms366723(VS.80).aspx Are they talking about compilation of C#...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.