From: Charles Thornton
GC of STW type does not collect the garbage while executing the program, memory is depleted, becoming, starting, it is the GC system which enters into the collection mode of the garbage. With this system, ���the time that stop���, because everything of the program is made to stop, the concept of ���the down time due to GC��� exists.
on the one hand, On-the-fly type GC can do execution of the program (allotment of the object which is included) with the collection of the garbage completely in parallel. Because there are no times when it enters into special mode in order to collect the garbage ���the stop with GC��� cannot occur, or almost can ignore.
When this story is heard, as On-the-fly type GC STW type GC compared to been superior as the system of GC, it is audible, but so the wholesaler does not lower. throughput (throughput) efficiency and the response (response) efficiency there is two as the index which chooses GC generally.as for On-the-fly type GC there is no stop with GC, response efficiency is very good. But, as for the actual GC algorithm which actualizes On-the-fly type GC throughput efficiency (operation of the time) low ones are many with especially multithread operation, the unique weak point (the object which has the reference which circulates mutually cannot be collected) have in addition depending upon algorithm.
on the one hand, as for STW type GC it is necessary to put ���the down time due to GC���, but is, the cost which catches when GC is not executed can be lower than On-the-fly type GC, raise throughput efficiency. So far because among the fields where Java language participates ray ten sea efficiency compared to there was many a thing where throughput efficiency is required, the majority of past JavaVM adopted STW type GC.
But, in the recent Java system it is it reaching the point where again [reitenshi] efficiency is seriously considered. You can use, it has increased the memory quantity which uses JavaVM attendant upon low price large increasing capacity of memory and the spread of 64 bit processor. Many of STW type GC algorithm because the memory quantity which GC has managed, the quantity of the object which has existed, it is proportionate to either of the numbers of references of the object which has existed, is a tendency where GC down time extends steadily. When the kind of memory which exceeds the gigabyte is used, the kind of pattern where the down time due to GC exceeds 10 seconds it has appeared.
because of that, the GC kind of algorithm which is compatible throughput efficiency and [reitenshi] efficiency becomes necessary. Below, Mostly where you express in this page Concurrent GC is the GC system like the child of the meeting of STW type and On-the-fly type.
Because (this chapter is cutting Hari from another document, the settlement is bad, but to an air.)
JavaVM of Java2SE JDK of Sun was mounted, the plural garbage collections (GC) algorithm was designed in such a way that it is changed according to the quality of application.
From Sun HotSpot VM 1.4.2 like below appointment is possible.
GC type Option Tendency proper Explanation Normal Unspecified Basis The classified by generation who combines Copying GC and Mark & Compact (Generational) GC. This becomes the basis. Parallel GC - XX: +UseParallelGC For server multiple CPU
Throughput concernBut normal the classified by generation GC who is similar, those which replace Copying GC of new generation side to Parallel Copying GC . Minor GC (1 processing times are short, occurrence frequency multi), Major GC (1 processing times are long, the time when the occurrence frequency small) inside Minor GC stops JavaVM is shortened and execution efficiency improves.
However because there is no improvement in Major GC, you do not improve the worst value of the response time.Concurrent GC - Xconcgc For server multiple CPU
Response concernBut classified by generation GC, old generation side those which replace Mostly-concurrent Mark & Sweep algorithm. Because the time when Major GC stops JavaVM is shortened, the worst value of the response time can be improved.
Additional option - XX: By the fact that it appoints +UseParNew , - XX: +UseParallelGC it can also use the parallel GC which is similar. In this case, also throughput efficiency is improved.
Here the concurrent (Concurrent) with as for the word which is said it is synonymous, On-the-fly.Incremental GC - Xincgc For client
Response concernIncremental GC which uses Train GC algorithm. The application whose memory size is small only with GC which works effectively, with this kind of application the down time of 1 GC can be shortened dramatically (below 64MB). However, throughput decreases.
When memory size was increased, throughput and the response decrease.
In this page the algorithm of new concurrent GC is explained.
The concurrent GC which HotSpot VM 1.4.x adopts is Mostly-concurrent Mark & Sweep .
As for this algorithm, Hans-J. Boehm and Alan J. 3 people of Demers and Scott Shenker announced [1] Mostly Parallel Garbage Collection (PLDI 1991) improved Tony Printezis and David Detlefs to the base [2] A Generational Mostly-concurrent Garbage Collection (ISMM 2000) are substantially in 1991. Later and M-CMS we have decided to abbreviate.
As for M-CMS Mark & Sweep algorithm have become the basis.
As for Mark & Sweep algorithm, when the program memory using up, when the thread which executes the program (it is JavaVM, the Java thread) making stop at one time, 1. 2. The face is executed in order.
2. When completes, JavaVM restarting the Java thread, reopens the program.
As for M-CMS Mark & Sweep aiming for the fact that the time when JavaVM stops the program is reduced, 1. Mark phase is improved. Previous GC ending, when the Java thread is reopened, simultaneously, the special marking thread which does marking processing in parallel, it executes M-CMS.
In other words, (1), (2), (3) and (4) object had lived at the point in time when GC ends, if is, the marking thread does as from Root (1) -> (2) -> (3) said to order, the marking. Also the Java thread becoming independent, because it is moving, before if the marking thread does mark processing, (3) -> (4) reference is separated, (4) is not done and the marking becomes the garbage.
There are two problematical points in this processing.
Among two problems (B) as for the excessive mark it is possible to ignore. When the object which becomes the rubbish ���you have lived���, that it is regarded GC the quantity of the object which survives increasing wastefully, memory is pressed, but if the other rubbish can be collected sufficiently, there is no problem in operation itself of the program. With M-CMS you do not collect the object which is marked in excess.
On the one hand, (A) a mark leak is not permitted under any condition. When there is a mark leak object, that mistaking with the next sweep phase, it is collected, becomes cause of fatal bug.
M-CMS copes in this mark leak like below.
First, as for the GC thread ���from Root reachable whether or not��� in order to check the mark was done in object, but separately from this sign of another type is acquired in order to check ���the object which is rewritten���. For example, when like below the thread which executes the Java program, reference of a some object is written to the field of
object1
, ���it was written���, the sign that is acquired in
object1
. This processing is called the
light/write barrier (write barrier)
with.
When object2 is not null, it checks with any object.
void method (Class1 object and Class2 object2) {
object1.field
= object2; }
It becomes as in the figure under the light/write barrier after being done, as an image in memory.
M-CMS was done ���concurrently��� in order to cope with a mark leak of the marking processing which, like usual Mark & Sweep stops JavaVM. And it is in heap memory, it keeps doing ���the object empty remaining marking processing which is rewritten midway���.
When it is the figure, (1), (2) and (3) becomes the start point of the marking, (5) it was leaking to the mark is discovered.
This way M-CMS marking processing, in parallel (the concurrent) the part where it does divides into the part which the mark (the serial) is done one by one.
The object which has become the garbage in the heap space which the mark ends is removed and the operation of making the free list is
sweeping (Sweeping)
with. As for Sweeping it is normal to include
Coalescing which
connects the empty territory which is continued.
To do concurrently it is possible this operation but is, for lightening the lock operation with Sun HotSpot VM 1.4.x the expectation which has not gone concurrently.
The dissertation of Printezis and others [ with 1] , you aim for the improvement of efficiency by the fact that M-CMS and classified by generation GC are combined. In this case, of new generation side GC Copying GC of Cheney style, M-CMS is used for the measure GC of old generation side minor.
As for Copying GC of minor GC side in order to do STW, GC down time exists. Simply thinking, that it is stop of the range where the down time of minor GC is short generally, in regard to use does not become inconvenient it allows this.
M-CMS of measure GC side like below obtains the merit by dividing the generation.
It is difficult simply to take the balance of mounting and speed.
In addition the dissertation of Printezis and others [ with 1] , the card marking (Card Marking) you have used for light/write barrier processing.
This is not to manage the object which has rewriting at the object unit, the heap space is divided fixed size (in dissertation 512 bytes) and manages (this the card). When it can rewrite the object inside the card, it is the system which all objects inside the card judge as rewriting. Object inside the card ���it became dirty, whether or not (it was rewritten)���, it is managed with the private table which is outside the heap space.
As for this you are moved by rough method, but because in regard to the mounting JavaVM the header of object is 2 words, there is no room which stuffs various items of information.
Light/write barrier processing like below becomes the cord/code. When executing the byte cord/code order of
putfield
,
putstatic
and
aastore
etc, it does together.
#define CARD_SIZE 512 #define DIRTY_MASK ((unsigned char) - 1)/* card table * unsigned char card_marking_table [CARD_SIZE]; void write_barrier (Object* object) {int offset = ((intptr_t) object)/CARD_SIZE; card_marking_table = DIRTY_MASK; }
To show clean or dirty vis-a-vis each card, it is possible to be 1 bits, but is, as for light/write barrier processing because it is done in parallel from the plural Java threads, in bit operation atomic (atomic) order becomes necessary. When that happens, the execution efficiency with multiple CPU becoming the abnormal play falling, it is topsy-turvydom. When
unsigned char
(8 bits) it consists, just a little wastefully the way, you can think, but because with most CPU reading and writing of 1 bytes becomes inseparable, atomic order and lock operation become unnecessary. In addition when acceleration of the GC algorithm of M-CMS is done, because give the plural parameters it stops wanting vis-a-vis one card there being a width a little, exactly, it is good.
Parallel GC (Parallel GC), allotting GC with the plural GC threads, it is the GC system which processes. Every single in case of M-CMS there are concurrent marking phase, serial marking phase and sweep phase three phases, but it is possible to convert each one in parallel.
Because Serial marking phase after making all Java threads stop, is the STW processing which is done, starting the GC thread of the same number as the quantity of CPU theoretically, if it decentralizes load, processing time becomes smallest, (the *2 ). That way it becomes minimization of GC down time and largest conversion of efficiency for processing time of Serial marking phase to become smallest.
On the one hand, as for concurrent marking phase and sweep phase because it is operational parallel with the Java thread, in order progress of the Java program and the progress of GC to become balance good, it is necessary to convert in parallel. In order basic for the speed where speed and the GC thread side where Java thread side consumes memory collect memory generally to become same, the number of GC threads which operate in parallel is adjusted.
Although the marking flag of position and the object where object exists is displayed, there is a method of preparing bit map outside the heap space. When we assume, that object has lined up into 8 byte boundary in the heap space, if bit map of 1/64 of heap spatial size is prepared, the heap space can be thoroughly contained.
The bit map 2 below is prepared.
It is possible to discover the position of the garbage by the fact that the bit map 2 is referred to the case of Sweep phase, to collect. Rather than licking the heap space, the person who refers to small bit map efficiency is much good.
However when bit map we assume that the thread which operates parallel parallel writes in simultaneously note becomes necessary. For the plural threads bit operation, atomic order is necessary. In order to lighten this, several it optimizes.
Because Mark & Sweep which include M-CMS leaving the object which has lived, keep releasing the object which has become the garbage, the space which is released (the free space) it does not become the space which is continued, the heap space keeps becoming pitted contact point state. It is fragmentation conversion. In order to evade this, shifting the position of the object which has lived, operation and the compaction which you move aside to one place (Compaction) becomes necessary.
Representation of compaction type GC with Mark & Compact, is something which replaces sweep phase of Mark & Sweep to compaction phase. Simply from the Java thread and it can process sweep concurrently, different, as for the compaction after from first making to last Java stop VM unless it does, useless. It depends on also the related characteristic of reference of object, but if only because as for marking phase and compaction phase the same time is required generally, marking became concurrent, GC down time it becomes half. Now excessively there is no effect.
[3] So Incremental Compaction which is proposed is the developmental system of M-CMS. The whole heap to abandon the compaction, in portion of the heap space the window for the compaction ( Evacuated Area; It does to the thing which is called EA ) it provides. The part other than the window sweeps with M-CMS, object inside the window does the compaction which is lined up to one side. The garbage being many in the window, the object which has lived uninformed by the fact that the space is chosen, can expand the free territory which is continued.
Being the window of portion of the proverb heap, when it will move the object which among those is it does, it is necessary to rewrite all pointers which point to the object which we would like to move. Remembering set (Remember Set) it uses in order to advance the movement of this object. As for remembering set you should have thought that it is the arrangement which records the pointer which points to EA.
putfield
,
putstatic
and
aastore
order, you watch, add to remembering set whether or not it is rewritten.
When Serial marking phase and Sweep phase complete, address of the object which refers to the EA territory from outside has entered entirely in remembering set. When it does, the area of influence is limited the compaction of object inside EA to the object which is recorded to remembering set. Targeting just the object which remembering set records it is possible to prevent the speed decrease with the compaction by rewriting portable address.
Incremental Compaction is mounted after the IBM JVM 1.4.2.