|Title of Invention||
A METHOD FOR IMPROVING THE EFFECTIVENESS OF A DATA PROCESSING APPLICATION WHEN USING A VIRTUAL MACHINE
|Abstract||A method for improving the effectiveness of a data processing application when using a virtual machine, wherein the program includes a large number of methods i.e. program sections, that are stored in the memory of the computer used, and wherein the program uses a garbage collecting procedure. The invention is characterized by analyzing in a first step all so called thread stacks with respect to the procedures required thereby; causing each of said requisite methods to be regenerated in a second step, wherein occurring references to a method prior to the regeneration are replaced with references to regenerated methods; and by erasing all non-regenerated methods in a third step and placing corresponding memory space at the disposal of the program.|
|Full Text||A METHOD FOR GARBAGE COLLECTION OF UNUSED METHODS
The present invention relates to a method of ingiroving tbe effectiveness of a data processing application.
More specifically, the invention is concerned with increasing the data processing rate in virtual machines, and then particalariy with respect to flie Java progiara langnagc.
The invention is not restricted to Java, but can be applied with many program languages, although the invention is desciibed below prrmarfly with reference to Java.
The method is intended for use with additive optiniisation of a prograni. In ad^tive optimisation, the program ia restroctured and diSerent parts of the program are optimi^d as die program is run. The general problem of mcreasing data processiiig edacity resides in the rapid creatitti of new m^emocy sites, since the longer the pro-am is run, the more memory space is required.
Java and other dynamic progxazs languages include an autoiiiatlc memory maoagement. This means that the programmer xieed not keep an account of those parts of the manoiy Hat ere used. The viitoal tn^fhinif cairies out a so-called garbage collection from time to time> meaning, in principle, that tbe virtual .maehine scans the entire memory and finds «^ch ol^ects have been stored m the memory and which die program can no longer address. These parts of tbe memory are retQzn£d for later use.
Java also includes methods for so calloi thread tnanagonent mei^ds. Thus, Java incoipbrates a system fbr supportzog or sjnulatirig the simultaneous processing of two or more programs. The thread managonent can be divided into two parts. One part concerns the maimer in which di^erent threads are structured in a controlled manner. Another part is conconed with which threads diall be nm and which threads shall he passive and wait to be run.
la order to further increase effectiveness and place occupied memory space at the disposal of the program, it is Eot sufficient to solely optimise the memory with respect to the objects.
The presenl invention, solves liiii problem.
The preseat invention ihas relates to a method of improvius the eSectiveness of a data processing application -wiicn using a virtual machine, whe-e the program includes many methods, i.6. program sections, that are stored in the zDemory of the con^utex used, and wbeis garble collecting is osed by said program, wherein the inventive method is characterised by a first step in ^vhich all so-called thread stacks are analysed with respect to methods required hereby, a second s^ in wfaidi ewih of the methods required is caused to be regenerated who"e occurreot refereoces to a method are replaced widi reference to regenerated methods |mor to the legouration of a method; and by a third step In which all non-regenraated methods are oased, whenan the cozresponding monory space IB placed at tile disposal of said prog^sm
The present invention will now be described in more detail partly with reference to an cxen^lifyiQg embodiment of the invenlian.shown on to flie accompanying drawing, in winch
- Figure I is a block diagram;
- Figure 2 illustralea old ix^sthoda; and
- Figure 3 illustrates methods regenerated in accordance with the inventioii.
Figure 1 ^lows that a Java virtual madime, JVM, can be used to run dj^exent data icograms 1, 2,3, regardless of whether flic operative system is WinNT, LINUX, Solaris or some other syst^n. As mentioDed above, altbou^ Java is a very popular pmgram language, the pieseift ioveotion is not restricted to this langu^e but t^n be appEed to all object-orientated and platform-ind^endcst cone^onding program languages.
The iBBsent invention tJios relates to a method of improving the effectiveness of a riptq pixxxssing ^(plication vvtea using a virtual machiae, wherein die program include a large number of methods, i-c. program sections, that are stored in fixe memory of die computer used, and -niaerein a garbage coUecting process is used by tbs program.
It is previously known to gaibage collect ottjects and therewith erase objects thai are no longer in current use the^y placing correspondiiig mcmoiy capacity at disposal.
In large systems, many methods, i.e. program sections, are used one or a few times, or methods are ^iplied for a shon poiod of time and then left ooused.
In the case of Java and coiresponding programs, new methods are loaded and old methods leftimused.
FuTthermore, ad^tive optimisanon results in die c^timisatiop and re-optimisation of metlKids placed in the memoiy, yffhexs old medKxte are le& unused.
When optimising loct mechanism selection and gaibage coUectioD. selection, it is necessary to r^Iace all used metiiods that use old medmoisms with, new niechamsms.
According xo the inveaitiDa, all so called iiaead stacks are analysed with respect to die m^ods reqinred, in a fitst sosp of ^as inveativB method. In a second step, each of the methods required is regenerated, where occuirait references to a method are replaced with teferences to regeoenited methods laior to said regeneraticm. la a third step, all non-x^enraated methods are erased and the correspondizig roemoiy space placed at the disposal of the program.
This procedare does not only cleaihout unused msdiods. but also results in a rcorganisatioD between those mdhods tiiac have been regenerated, so as to direct references of the m^ods immediately to a regenerated method instead of proceeding via an old method that is no tonga-used,
This is illustrated in Figures 2 and 3, of whidi Figtire 2 illustrates old m^ods and Figure 3 iBustrates used regenerated methods. Three mdhods fix>, apa and bar are shown, in Figure 2. Foo starts on the memory address 4711. .^a starts an the address 4714 and bar starts on the address 4720.
Analysis of the thread stacks shows that only the methods foo and bar arc used, and consequently fbo and bar have not been referenced to the methjsd ^a.
The me^d ibo and bar are re^enefated to those methods illustrated in Figure 3. In &is case, the mrfhods &o and bar are recreated precisely, although with the differeoce that tiie metiiods obtain new addresses and that thai die foo lefsrence to bar points to the new bar address 4903.
All old methods, i.e. ihs methods in Figure 2, are erased and fee memory spaces previously occupied by these methods are vacated &r fiirdier use.
When garbage collection of olriects talces place, running of Hie program normally stops wMle garbage collection takes place. Rumring of the progiaxn is restarted subsequent to the garbage collection and to the erasure of objects ttiat are not in use.
Sodi a method can be lued when f^lying &e present invesition.
However, it ia very mucit preferred to \ise the. foUcfwing method instead.
Whea ptacticing the inventive method, ooe thread is sti^iped at a time whilst tlie program is running, wherewith methods u^d for a. stopped thread are transferred to a Ust and the thread thai restamd. The methods in the list are thsi reg«iaated and stored. AH threads are later caused to be stopped at tiie sam« time, subsequent to having trca»d all threads in tbis way, namely so.that all us«l methods relating to the &reads concerned have been regmerated. All mefliods ibat have not been r^eoerated are erased and all threads are restarted wiOi the regeneiated methods.
This mcttuid obviates the need to stop nmnigg the program, since the regeneratiDn takes place intcimittently.
As before xuentioDed, lock mechamsips arc nsed in Java and corresponding languages. DiSrmit lock mechanisms can be selected. The important thing is to select the lock necfaanism that is the most elective in preventijig more flian one thread having access to a ;iven object at the same time as another thread.
A synchxonisation problem exists when several threads desire access to one and the same object or source. In order to solve Qas problem in Java, each thread endeavours to reach the source lock. The source lock mechamsm can be used in various ways. The effectiveness of diffaent lock mechanisms will depend on how threads endeavour to obtain access to syuchonised sources.
According to a preferred embodiment, whai lockimg mechanisms are "used the most elective locking mecbaniom are identified in a step prjcff to said first step, and the methods that use a thus identified locking medbanism are regenerated.
With respect to garbage collecting algorithms, ihese also need to be selected. Many object orientated languages use garbage coUectioa. This means that the progiammer need not iustnict the system explicitly lliat a certain object is rro longer r^uired. The system is Tssponsible for this detection, and reclainu the part of the memory occupied by the object A number of difCisreat algotitiims have been pn^xised for elective implementation of diis detection and .tedlaim. It has been &UQd diat difEecort algorithms are best for difieiait ^yplications. The choice of the best garble collecting algoiidnn for the program qjplication being run is M^y significant in achieving maximum execution rate in respect of the program coocemed.
According to ano&er pre&ned embodaneat of the invention, when di£fereat garbage collecting algori&ms are used tiie allocation and length of life of the various objects are determined in a step prior to said first method stepy whereafter die most effective gaiiiage collecting algorilbm is camed to be identified and lire methods constitutiiig the requisite gaifaage collecting algoridmis are regeoerated sad remaining garbage coHectiag algorithms then erased.
.^jplication of flie preferred embodiments provides a highly effective method for opdniisiiig codes, tbreads and memory management, where a gowiic feature resides in the identificatioD and r^citsradoii of m^ods so as to not load the system wi& imnsed methods.
WE CLAIM :
1. A method for improving the effectiveness of a data processing appHcation when using a virtual machine, wherein the program includes a large number of methods, i,e. program sections, that are stored in the memory of the computer used, and wherein the program uses a garbage collecting procedure, characterised by analysing in a first step all so called thread stacks with respect to the methods required thereby; causing each of said requisite methods to be regenerated in a second step, wherein occurring references to a method prior to regeneration are replaced with references to regenerated methods; and by erasing all non-regenerated methods in a third step and placing corresponding memory space at the disposal of the program.
2. A method as claimed in Claim 1, comprising causing one thread at a time to be stopped as the program is run; transferring methods used for a stopped thread to a list, and thereafter restarting the thread; regenerating and storing the methods in said list; causing all threads to be stopped simultaneously subsequent to having treated all threads in said fashion; erasing all methods that have not been regenerated and restarting all threads with the regenerated methods.
3. A method as claimed in Claims 1 or 2, comprising when locking mechanisms are used identifying the most effective locking mechanism In a step prior to said first method step; and regenerating those methods that use a thus identified locking mechanism.
4. A method as claimed in Claims 1,2 or 3, comprising, when different garbage collecting algorithms are used, determining the allocation and length of Hfe of the
various objects in a step prior to said first method sep, and then identifying the most effective garbage collecting algorithm; regenerating the methods constituting the requisite garbage collecting algorithms; and erasing remaining garbage collecting algorithms.
|Indian Patent Application Number||IN/PCT/2002/616/CHE|
|PG Journal Number||05/2007|
|Date of Filing||26-Apr-2002|
|Name of Patentee||M/S. APPEAL VIRTUAL MACHINES AB|
|Applicant Address||BOX 2189, S-103 15 STOCKHOLM,|
|PCT International Classification Number||G06P 12/02|
|PCT International Application Number||PCT/SE00/02096|
|PCT International Filing date||2000-10-27|