jdk/src/jdk.hprof.agent/share/native/libhprof/README.txt
author tschatzl
Wed, 19 Aug 2015 13:59:39 +0200
changeset 32379 aa14adafaf0f
parent 26201 40a873d21081
permissions -rw-r--r--
8073013: Add detailed information about PLAB memory usage Summary: Track and provide information about direct allocation, region end waste and failure waste for G1. Reviewed-by: jmasa, david, ehelin, mgerdin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
README
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
Design and Implementation:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    * The Tracker Class (Tracker.java & hprof_tracker.c)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        It was added to the sun.tools.hprof.Tracker in JDK 5.0 FCS, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
	moved to a package that didn't cause classload errors due to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
	the security manager not liking the sun.* package name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
	5091195 detected that this class needs to be in com.sun.demo.jvmti.hprof.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        The BCI code will call these static methods, which will in turn
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        (if engaged) call matching native methods in the hprof library,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
	with the additional current Thread argument (Thread.currentThread()).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
	Doing the currentThread call on the Java side was necessary due
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
	to the difficulty of getting the current thread while inside one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
	of these Tracker native methods.  This class lives in rt.jar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    * Byte Code Instrumentation (BCI)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        Using the ClassFileLoadHook feature and a C language
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        implementation of a byte code injection transformer, the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        bytecodes get injections:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
	    - On entry to the java.lang.Object <init> method, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
	      a invokestatic call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
		Tracker.ObjectInit(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
	      is injected. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
	    - On any newarray type opcode, immediately following it, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
	      the array object is duplicated on the stack and an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
	      invokestatic call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
		Tracker.NewArray(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
	      is injected. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
	    - On entry to all methods, a invokestatic call to 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
		Tracker.CallSite(cnum,mnum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
	      is injected. The hprof agent can map the two integers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
	      (cnum,mnum) to a method in a class. This is the BCI based
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
	      "method entry" event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
	    - On return from any method (any return opcode),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
	      a invokestatic call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
		Tracker.ReturnSite(cnum,mnum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
	      is injected.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        All classes found via ClassFileLoadHook are injected with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        exception of some system class methods "<init>" and "finalize" 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        whose length is 1 and system class methods with name "<clinit>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
	and also java.lang.Thread.currentThread() which is used in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
	class Tracker (preventing nasty recursion issue).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        System classes are currently defined as any class seen by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
	ClassFileLoadHook prior to VM_INIT. This does mean that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
	objects created in the system classes inside <clinit> might not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
	get tracked initially.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
	See the java_crw_demo source and documentation for more info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
	The injections are based on what the hprof options
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
	are requesting, e.g. if heap=sites or heap=all is requested, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
	newarray and Object.<init> method injections happen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
	If cpu=times is requested, all methods get their entries and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
	returns tracked. Options like cpu=samples or monitor=y
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
	do not require BCI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    * BCI Allocation Tags (hprof_tag.c)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        The current jlong tag being used on allocated objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
	is an ObjectIndex, or an index into the object table inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
	the hprof code. Depending on whether heap=sites or heap=dump 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
	was asked for, these ObjectIndex's might represent unique
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
	objects, or unique allocation sites for types of objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
	The heap=dump option requires considerable more space
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
	due to the one jobject per ObjectIndex mapping.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    * BCI Performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        The cpu=times seems to have the most negative affect on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
	performance, this could be improved by not having the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
	Tracker class methods call native code directly, but accumulate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
	the data in a file or memory somehow and letting it buffer down
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
	to the agent. The cpu=samples is probably a better way to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
	measure cpu usage, varying the interval as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
	The heap=dump seems to use memory like crazy, but that's 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
	partially the way it has always been. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    * Sources in the JDK workspace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        The sources and Makefiles live in:
26201
40a873d21081 8043936: Drop HPROF as demo, keep as HPROF agent shipped with JDK
sla
parents: 25859
diff changeset
   109
                src/jdk.hprof.agent/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                src/share/demo/jvmti/java_crw_demo/*
26201
40a873d21081 8043936: Drop HPROF as demo, keep as HPROF agent shipped with JDK
sla
parents: 25859
diff changeset
   111
                make/lib/Lib-jdk.hprof.agent.gmk
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
   
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
--------