United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6765745 par compact - allow young gen spaces to be split
JDK-6765745 : par compact - allow young gen spaces to be split

Details
Type:
Enhancement
Submit Date:
2008-10-30
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2009-01-31
Component:
hotspot
OS:
generic
Sub-Component:
gc
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0u6
Fixed Versions:
hs14 (b09)

Related Reports
Backport:
Backport:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
During a full gc, all live objects in the young gen are copied to the old gen as long as there is enough space.  When the heap is very full, all the young gen objects may not fit.  With par compaction, this often results in a long series of time-consuming full gcs which do not free up space in eden.  When par compact is copying from a young gen space (e.g., eden or from) to the old gen, *all* live objects in the space must fit into the old gen; otherwise, none of them will be copied.  This is because par compaction operates on fixed-size 'regions' of the heap and copying only part of a space would require extra bookkeeping (or some good luck).

The extra bookkeeping should be implemented to allow a young gen space to be "split" so that as much as will fit is copied to the old gen and the rest is compacted down within the young gen space itself.

                                    

Comments
EVALUATION

Since par compact operates on fixed-size regions of the heap, a space can only be split at a region boundary to avoid dramatically slowing down the calculation of the new location of a pointer (a very hot code path). Since objects cannot be split, a split must be done at a region boundary that is not spanned by a live object.  When a split is necessary (very full heap), such boundaries are scarce.

Par compact already keeps track of partial objects--which are the tail ends of objects which span region boundaries.  Given this and a little extra bookkeeping, a region can be split just after the end of a partial object without affecting hot code paths.

When splitting a region, the partial object and everything to its left will be copied to another space (call it destination space 1, or d1).  The live data to the right of the partial object will be copied either within the space itself, or to another destination space (d2, which is distinct from d1).  Since the partial object will have no effect on the locations of other objects destined for d2, the data about the partial object can be saved in a side data structure and removed from the main summary table (summary_data).

More specifically, when the par compact summary phase determines that a region needs to be split, it records the following in a separate "SplitInfo" table:

	the region being split
	the size of the partial object crossing onto the region
	the destination address of the first word of the partial object
	the destination count of the partial object (the number of regions it will be copied to--1 or 2)
	the destination region boundary (if it will be copied to 2 regions)
	the address of the first word within the partial object to be copied to the second destination region
		(again if it will be copied to 2 regions)

A space is split at most once, so the amount of data is small and fixed size.  The info is needed only when finding the first word to be copied to a destination region, which is done once per region and so has no noticeable effect on performance.  The tricky part is recording the data properly during the summary phase.
                                     
2008-10-30
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/7c2386d67889
                                     
2008-12-12
SUGGESTED FIX

Attached.
                                     
2008-12-12



Hardware and Software, Engineered to Work Together