Re: Improving first access to a web service

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Derek Harmon (loresayer_at_msn.com)
Date: 03/13/05


Date: Sat, 12 Mar 2005 23:40:55 -0500


"Olorin" <francesco.rizzi@gmail.com> wrote in message news:1110685767.867711.249920@g14g2000cwa.googlegroups.com...
> Here's my current understanding of this 'first-invokation' problem.
> Please correct me if I'm wrong.
: :
> This happens for all .NET apps, but we notice it more in Web APps
> becaise, as the JIT compiler compiles a web app or a web service, it
> must compile the code needed to serialize/deserialize all the data
> types exposed by the web app or web service public API.

For a WebMethod, the Framework:
1.) Reflects against the types appearing in the signature of the method using
reflection to get all their properties (and reflects against those properties'
types if necessary, i.e. if the property had a compound type).
2.) Writes C# source code to serialize and deserialize them and saves
this into a file in your temp directory (cleans it up too, unless you set a
certain diagnostic switch instructing it to leave it there).
3.) Launches the C# compiler to compile that source code.
4.) Loads the dynamically generated assembly into memory and starts using
its serialization/deserialization class to handle the XML.

For an ASP.NET application it's a little different:
1.) Reads and parses the .ASPX file, which is a 'template' describing the
hierarchy of controls on the page and their initial settings.
2.) Writes C# source code to create the control hierarchy that fills the Page
and saves this into a file deep beneath your Temporary ASP.NET Files
directory.
3.) Launches the C# compiler to compile that source code.
4.) Saves the dynamically generated assembly alongside the source file.

It's machines writing programs for themselves and then loading systems
software like you or I would do that's the slow part.

These processes aren't known to the JIT compiler. The Serialization
process affecting WebMethods happens after code has been JIT into
machine code, only as it executes to the point where an XmlSerializer
object gets constructed for a given Type the first time. Conversely,
the ASP.NET process happens before the JIT even sees the IL in
an assembly (because the ASP.NET process is responsible for
producing the assembly the JIT receives when it doesn't already
exist or is out-of-date).

Derek Harmon



Relevant Pages

  • RE: Suppress JIT Debugger?
    ... Try setting up debug versus production code rather than suppressing the JIT ... compiler. ... Remember that HIT compilation is necessary for apps, ...
    (microsoft.public.dotnet.framework)
  • Re: 5.1b cc optimizer problem?
    ... the compiler hasn't changed a whole lot in 5.1B, ... Optimization can uncover some source code issues that lay dormant before. ... >crashes with several locally-compiled apps, ...
    (comp.unix.tru64)
  • c++ programming 64 bit applications
    ... what will change in c++ programming for 64 bit apps. ... Will the source code be different or just the compiler? ...
    (alt.comp.lang.learn.c-cpp)
  • Re: GPL vs non-GPL device drivers
    ... shipped the source code of the modified POP server. ... given you the compiler he compiled it with, ... Actually, if memory serves, when you license a work under the GPL, part of the ... a derivative work" the claim is invalid - because, as it has been shown, a ...
    (Linux-Kernel)
  • Re: more compiler switches
    ... Also print the version number of the compiler ... driver program and of the preprocessor and the compiler proper. ... C source code which should not be preprocessed. ... Like -v except the commands are not executed and all command arguments are ...
    (comp.lang.fortran)