Many applications and libraries are distributed in an intermediate format, such as MICROSOFT® Intermediate Language (MSIL). These intermediate language binaries (also known as managed assemblies in the case of MICROSOFT®.NET) are typically compiled dynamically at runtime in a virtual machine environment using a Just-in-Time (JIT) compiler. An alternative to dynamic compilation is pre-compilation via Native Generation (NGen). NGen generates machine code and runtime data structures from the intermediate language and persists them in files on disk. The images produced by NGen are called Native or NGen images. Unlike JIT-compiled code, code and data structures in NGen images can be shared across processes. For libraries and frameworks that are typically shared across multiple processes, NGen is extremely useful since it minimizes the working set of each managed process. NGen therefore reduces the overall memory utilization of the system. NGen is also very useful for minimizing start up time of client-side applications.
Several managed platforms/applications are using NGen. Unfortunately, however, it is quite difficult to use NGen in these current platforms. Since NGen images need to be created on the end-user machine, NGen commands need to be chained through the framework/application's installer. Typically, that involves writing a custom action (such as a MIROSOFT® WINDOWS® Installer action) that invokes a command-line tool (ngen.exe in the case of MICROSOFT® .NET).Custom actions are not trivial to write. Moreover, NGen images may become invalidated for a variety of reasons (such as when the corresponding libraries/assemblies are serviced), and need to be regenerated each time that happens by issuing explicit commands through the command line tool.
Various technologies and techniques are disclosed for automatically generating native images for a virtual machine environment. A virtual machine environment is provided where application libraries are distributed in an intermediate language format and then compiled at a later point in time. An automatic native generation service is provided that monitors the application libraries and generates a native image for a particular one or more of the application libraries when the service determines that native generation is appropriate.
In one implementation, native generation is determined to be appropriate by monitoring how frequently a particular application library is used, and then regenerating the application libraries in order of frequency of usage. In another implementation, native generation is determined to be appropriate by reading an identifier associated with a particular application library indicating it has been opted into native generation.
Invalid native images are automatically detected and re-generated. For example, if a load attempt for a particular native image is unsuccessful, then the native image is determined to be invalid. The particular native image is then regenerated automatically.
This Summary was provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
For the purposes of promoting an understanding of the principles of the invention, reference will now be made to the embodiments illustrated in the drawings and specific language will be used to describe the same. It will nevertheless be understood that no limitation of the scope is thereby intended. Any alterations and further modifications in the described embodiments, and any further applications of the principles as described herein are contemplated as would normally occur to one skilled in the art.
The system may be described in the general context as an application that automatically generates native images (NGen images) in a virtual machine environment, but the system also serves other purposes in addition to these. In one implementation, one or more of the techniques described herein can be implemented as features within a framework program such as MICROSOFT® .NET Framework, Java Virtual Machine, or from any other type of program or service that deals with an intermediate language and then needs to compile that intermediate language into machine code for execution on a target machine.
As shown in
Additionally, device 100 may also have additional features/functionality. For example, device 100 may also include additional storage (removable and/or non-removable) including, but not limited to, magnetic or optical disks or tape. Such additional storage is illustrated in
Computing device 100 includes one or more communication connections 114 that allow computing device 100 to communicate with other computers/applications 115. Device 100 may also have input device(s) 112 such as keyboard, mouse, pen, voice input device, touch input device, etc. Output device(s) 111 such as a display, speakers, printer, etc. may also be included. These devices are well known in the art and need not be discussed at length here. In one implementation, computing device 100 includes automatic native generation application 200. Automatic native generation application 200 will be described in further detail in
Turning now to
Automatic native generation application 200 includes program logic 204, which is responsible for carrying out some or all of the techniques described herein. Program logic 204 includes logic for providing an automatic native generation service for a virtual machine environment 206; logic for monitoring application libraries used in the virtual machine environment 208; logic for generating and/or re-generating a native image from an intermediate language for one or more of the application libraries when the service determines that native generation is appropriate 210; logic for determining that native generation is appropriate at least in part by reading a native generation attribute associated with each of the application libraries 212; logic for determining that native generation is appropriate at least in part by tracking a load counter for each of the application libraries, sorting the load counter for each of the application libraries, and using the sorted load counters to determine an order in which to generate the native image for some or all of the application libraries 214; logic for determining that native generation is appropriate for a given one or more libraries by using heuristics (e.g. tracking which libraries are used simultaneously by multiple processes and would benefit from native generation, etc.) 216; and other logic for operating the application 220. In one implementation, program logic 204 is operable to be called programmatically from another program, such as using a single call to a procedure in program logic 204.
Turning now to
An automatic native generation service is provided that monitors the application libraries and generates a native image (e.g. synchronously before image load is completed, asynchronously immediately following the image load, or asynchronously when the machine is idle) for a particular one or more of the application libraries when the service determines that native generation and/or re-generation is appropriate (stage 244). One or more combinations of heuristics, tracking load counters, determining the old native image is invalid, reading a native generation attribute specified by a developer, and/or other rules of logic can be used to determine that native generation is appropriate (stage 244). As one non-limiting example, a developer can set a native generation attribute for a particular library/assembly, and the system can then read that attribute to determine that the developer wishes to opt-in to native generation. Some additional non-limiting examples are described in further detail in
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. All equivalents, changes, and modifications that come within the spirit of the implementations as described herein and/or by the following claims are desired to be protected.
For example, a person of ordinary skill in the computer software art will recognize that the client and/or server arrangements, and/or data layouts as described in the examples discussed herein could be organized differently on one or more computers to include fewer or additional options or features than as portrayed in the examples.
Number | Name | Date | Kind |
---|---|---|---|
6110226 | Bothner | Aug 2000 | A |
6151703 | Crelier | Nov 2000 | A |
6289506 | Kwong et al. | Sep 2001 | B1 |
6484313 | Trowbridge et al. | Nov 2002 | B1 |
6760907 | Shaylor | Jul 2004 | B2 |
6964039 | Heeb | Nov 2005 | B2 |
6978451 | Heeb | Dec 2005 | B2 |
7171655 | Gordon et al. | Jan 2007 | B2 |
7730468 | Trowbridge | Jun 2010 | B1 |
20020144240 | Lueh et al. | Oct 2002 | A1 |
20030084432 | Kobayashi | May 2003 | A1 |
20040083467 | Hanley et al. | Apr 2004 | A1 |
20040123278 | Nanja et al. | Jun 2004 | A1 |
20040158813 | Xia et al. | Aug 2004 | A1 |
20040255268 | Meijer et al. | Dec 2004 | A1 |
20050065936 | Goering | Mar 2005 | A1 |
20050108692 | Lau et al. | May 2005 | A1 |
20050273769 | Eichenberger et al. | Dec 2005 | A1 |
20060101438 | Mariani | May 2006 | A1 |
20060101446 | Mariani et al. | May 2006 | A1 |
20060136712 | Nagendra et al. | Jun 2006 | A1 |
20070061787 | Trowbridge | Mar 2007 | A1 |
20070226715 | Kimura et al. | Sep 2007 | A1 |
20070245324 | Inglis et al. | Oct 2007 | A1 |
20070294679 | Bobrovsky et al. | Dec 2007 | A1 |
Number | Date | Country |
---|---|---|
0997816 | May 2000 | EP |
Number | Date | Country | |
---|---|---|---|
20080098368 A1 | Apr 2008 | US |