United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6797870 Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
JDK-6797870 : Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC

Details
Type:
Enhancement
Submit Date:
2009-01-26
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
hotspot
OS:
generic,solaris_10
Sub-Component:
gc
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u7,7
Fixed Versions:
hs15 (b03)

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

Sub Tasks

Description
Add a -XX:+HeapDumpBeforeFullGC that produces a heap dump when a full gc becomes necessary,
whether because of a promotion failure, concurrent mode failure, explicit request or other
reason.  The heap dump can then be analyzed to discover which objects/classes dominate the
set of live objects and thus provide clues to application developers about which objects
and classes to focus on so as to decrease or eliminate the chances of a full gc.  The
heap dump should not increase full gc time by more than 15%.  This is a somewhat vague
number since full gc time depends on things like the percentage of live data in the heap,
but it gives a sense of the tolerable overhead.
Modified synopsis from the original:-

  "Add -XX:+HeapDumpBeforeFullGC"

to:-

   " Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC"

based on discussions (also with requesting customer).

                                    

Comments
EVALUATION

See suggested fix section; solution under test and review.
                                     
2009-02-23
SUGGESTED FIX

A preliminary webrev is available here:-

   http://analemma.sfbay/net/spot/workspaces/ysr/dump/webrev
                                     
2009-02-23
EVALUATION

If the user specifies -XX:+ExplicitGCInvokesConcurrent* when using CMS, then the ensuing
GC upon a System.gc() invocation is usually a concurrent GC, rather than one of the
stop-world variety. In such cases, there are no dumps or histograms produced.
In other words, these dumps and/or histograms are produced only upon a major
stop-world gc.

Moreover, the 15% delta is being treated as advisorial in nature at the moment.
Clearly, with a heap dump it is nearly impossible to meet such a constraint
for general heaps; with a class histogram there is some chance of meeting that
constraint, but it is by no means certain that we shall be able to meet it
in a first writing without further optimization of the current histogram
collection code. However, it is true that with sufficient parallelization
of the histogram collection, it should be possible to make the histogram
collection quite efficient, but that is a separate performance RFE, not
the current feature RFE.
                                     
2009-02-23
EVALUATION

Will, like 6808808, need CCC approval before it becomes officially
supported. Will also need to be reviewed by the serviceability and
tools groups.
                                     
2009-02-23
EVALUATION

6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC

webrev: http://analemma.sfbay.sun.com/net/spot/workspaces/ysr/dump/webrev/

This is an RFE request from a financial sector customer.
See description section of the CR for their request.
Above, "Full GC" is any stop-world major gc.

When HeapDump{Before,After}FullGC is specified you get
a heap dump prior to (respectively immediately
following) a full gc. The file name for the first
such dump follows exactly the rules used for other
HeapDump* flags. Subsequent dumps append a successor
ordinal number to the name used in the first dump.

When PrintClassHistogram{Before,After}FullGC is specified
you get a class histogram of the usual kind either just
prior to or immediately following a full gc. The data
is sent to the same stream to which PrintClassHistogram
data would have gone (usually gclog file if one was
specified, and otherwise to stdout).

All flags are "manageable" and can be dynamically toggled.

Although many files have been touched, the changes are few
and the main ones limited to two files.
A main technical change in the implementation was a
suitable modification of the relevant dumping/histogram
code so that it could be called directly from the VM
thread rather than as a VM operation. This allowed us
to precisely position the snapshot for example between
a failed scavenge because of promotion failure
and the full collection that we bail out to.

While in a strict technical sense this functionality cannot
be exactly simulated using a combination of existing
tools such as jmap -dump or jmap -histo[:live], in conjunction
with suitably placed Dtrace probes, a pretty close
approximation can indeed be achieved. Of course, these
flags allow such debugging on platforms that do not support
Dtrace. Also the customer requesting the RFE was adamant that
this functionality was needed by them.

A separate RFE is extending histogram presentations to
be relativized per generation and will be available for
review in the next day or two.

The code has been tested manually under a variety of
conditions, and is being tested/evaluated by the customer.

PS: <deleted>

PPS: The RFE will be extended to G1 under a separate CR.
                                     
2009-02-27
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/c6c601a0f2d6
                                     
2009-03-03



Hardware and Software, Engineered to Work Together