提交 c645eadd 编写于 作者: T tonyp

7097586: G1: improve the per-space output when using jmap -heap

Summary: Extend the jmap -heap output for G1 to include some more G1-specific information.
Reviewed-by: brutisso, johnc, poonam
上级 a5e75e63
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -49,8 +49,12 @@ public class G1CollectedHeap extends SharedHeap { ...@@ -49,8 +49,12 @@ public class G1CollectedHeap extends SharedHeap {
static private long g1CommittedFieldOffset; static private long g1CommittedFieldOffset;
// size_t _summary_bytes_used; // size_t _summary_bytes_used;
static private CIntegerField summaryBytesUsedField; static private CIntegerField summaryBytesUsedField;
// G1MonitoringSupport* _g1mm // G1MonitoringSupport* _g1mm;
static private AddressField g1mmField; static private AddressField g1mmField;
// MasterOldRegionSet _old_set;
static private long oldSetFieldOffset;
// MasterHumongousRegionSet _humongous_set;
static private long humongousSetFieldOffset;
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
...@@ -67,12 +71,14 @@ public class G1CollectedHeap extends SharedHeap { ...@@ -67,12 +71,14 @@ public class G1CollectedHeap extends SharedHeap {
g1CommittedFieldOffset = type.getField("_g1_committed").getOffset(); g1CommittedFieldOffset = type.getField("_g1_committed").getOffset();
summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used"); summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
g1mmField = type.getAddressField("_g1mm"); g1mmField = type.getAddressField("_g1mm");
oldSetFieldOffset = type.getField("_old_set").getOffset();
humongousSetFieldOffset = type.getField("_humongous_set").getOffset();
} }
public long capacity() { public long capacity() {
Address g1CommittedAddr = addr.addOffsetTo(g1CommittedFieldOffset); Address g1CommittedAddr = addr.addOffsetTo(g1CommittedFieldOffset);
MemRegion g1_committed = new MemRegion(g1CommittedAddr); MemRegion g1Committed = new MemRegion(g1CommittedAddr);
return g1_committed.byteSize(); return g1Committed.byteSize();
} }
public long used() { public long used() {
...@@ -94,6 +100,18 @@ public class G1CollectedHeap extends SharedHeap { ...@@ -94,6 +100,18 @@ public class G1CollectedHeap extends SharedHeap {
return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr); return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr);
} }
public HeapRegionSetBase oldSet() {
Address oldSetAddr = addr.addOffsetTo(oldSetFieldOffset);
return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class,
oldSetAddr);
}
public HeapRegionSetBase humongousSet() {
Address humongousSetAddr = addr.addOffsetTo(humongousSetFieldOffset);
return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class,
humongousSetAddr);
}
private Iterator<HeapRegion> heapRegionIterator() { private Iterator<HeapRegion> heapRegionIterator() {
return hrs().heapRegionIterator(); return hrs().heapRegionIterator();
} }
......
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -77,6 +77,10 @@ public class G1MonitoringSupport extends VMObject { ...@@ -77,6 +77,10 @@ public class G1MonitoringSupport extends VMObject {
return edenUsedField.getValue(addr); return edenUsedField.getValue(addr);
} }
public long edenRegionNum() {
return edenUsed() / HeapRegion.grainBytes();
}
public long survivorCommitted() { public long survivorCommitted() {
return survivorCommittedField.getValue(addr); return survivorCommittedField.getValue(addr);
} }
...@@ -85,6 +89,10 @@ public class G1MonitoringSupport extends VMObject { ...@@ -85,6 +89,10 @@ public class G1MonitoringSupport extends VMObject {
return survivorUsedField.getValue(addr); return survivorUsedField.getValue(addr);
} }
public long survivorRegionNum() {
return survivorUsed() / HeapRegion.grainBytes();
}
public long oldCommitted() { public long oldCommitted() {
return oldCommittedField.getValue(addr); return oldCommittedField.getValue(addr);
} }
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.gc_implementation.g1;
import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.types.AddressField;
import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
// Mirror class for HeapRegionSetBase. Represents a group of regions.
public class HeapRegionSetBase extends VMObject {
// size_t _length;
static private CIntegerField lengthField;
// size_t _region_num;
static private CIntegerField regionNumField;
// size_t _total_used_bytes;
static private CIntegerField totalUsedBytesField;
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
static private synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("HeapRegionSetBase");
lengthField = type.getCIntegerField("_length");
regionNumField = type.getCIntegerField("_region_num");
totalUsedBytesField = type.getCIntegerField("_total_used_bytes");
}
public long length() {
return lengthField.getValue(addr);
}
public long regionNum() {
return regionNumField.getValue(addr);
}
public long totalUsedBytes() {
return totalUsedBytesField.getValue(addr);
}
public HeapRegionSetBase(Address addr) {
super(addr);
}
}
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -67,6 +67,7 @@ public class HeapSummary extends Tool { ...@@ -67,6 +67,7 @@ public class HeapSummary extends Tool {
printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap)); printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap));
printValMB("PermSize = ", getFlagValue("PermSize", flagMap)); printValMB("PermSize = ", getFlagValue("PermSize", flagMap));
printValMB("MaxPermSize = ", getFlagValue("MaxPermSize", flagMap)); printValMB("MaxPermSize = ", getFlagValue("MaxPermSize", flagMap));
printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes());
System.out.println(); System.out.println();
System.out.println("Heap Usage:"); System.out.println("Heap Usage:");
...@@ -100,11 +101,20 @@ public class HeapSummary extends Tool { ...@@ -100,11 +101,20 @@ public class HeapSummary extends Tool {
} else if (sharedHeap instanceof G1CollectedHeap) { } else if (sharedHeap instanceof G1CollectedHeap) {
G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap; G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap;
G1MonitoringSupport g1mm = g1h.g1mm(); G1MonitoringSupport g1mm = g1h.g1mm();
System.out.println("G1 Young Generation"); long edenRegionNum = g1mm.edenRegionNum();
printG1Space("Eden Space:", g1mm.edenUsed(), g1mm.edenCommitted()); long survivorRegionNum = g1mm.survivorRegionNum();
printG1Space("From Space:", g1mm.survivorUsed(), g1mm.survivorCommitted()); HeapRegionSetBase oldSet = g1h.oldSet();
printG1Space("To Space:", 0, 0); HeapRegionSetBase humongousSet = g1h.humongousSet();
printG1Space("G1 Old Generation", g1mm.oldUsed(), g1mm.oldCommitted()); long oldRegionNum = oldSet.regionNum() + humongousSet.regionNum();
printG1Space("G1 Heap:", g1h.n_regions(),
g1h.used(), g1h.capacity());
System.out.println("G1 Young Generation:");
printG1Space("Eden Space:", edenRegionNum,
g1mm.edenUsed(), g1mm.edenCommitted());
printG1Space("Survivor Space:", survivorRegionNum,
g1mm.survivorUsed(), g1mm.survivorCommitted());
printG1Space("G1 Old Generation:", oldRegionNum,
g1mm.oldUsed(), g1mm.oldCommitted());
} else { } else {
throw new RuntimeException("unknown SharedHeap type : " + heap.getClass()); throw new RuntimeException("unknown SharedHeap type : " + heap.getClass());
} }
...@@ -216,9 +226,11 @@ public class HeapSummary extends Tool { ...@@ -216,9 +226,11 @@ public class HeapSummary extends Tool {
System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used"); System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used");
} }
private void printG1Space(String spaceName, long used, long capacity) { private void printG1Space(String spaceName, long regionNum,
long used, long capacity) {
long free = capacity - used; long free = capacity - used;
System.out.println(spaceName); System.out.println(spaceName);
printValue("regions = ", regionNum);
printValMB("capacity = ", capacity); printValMB("capacity = ", capacity);
printValMB("used = ", used); printValMB("used = ", used);
printValMB("free = ", free); printValMB("free = ", free);
......
...@@ -1886,6 +1886,10 @@ void ConcurrentMark::cleanup() { ...@@ -1886,6 +1886,10 @@ void ConcurrentMark::cleanup() {
// races with it goes around and waits for completeCleanup to finish. // races with it goes around and waits for completeCleanup to finish.
g1h->increment_total_collections(); g1h->increment_total_collections();
// We reclaimed old regions so we should calculate the sizes to make
// sure we update the old gen/space data.
g1h->g1mm()->update_sizes();
if (VerifyDuringGC) { if (VerifyDuringGC) {
HandleMark hm; // handle scope HandleMark hm; // handle scope
gclog_or_tty->print(" VerifyDuringGC:(after)"); gclog_or_tty->print(" VerifyDuringGC:(after)");
......
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -59,6 +59,7 @@ class HRSPhaseSetter; ...@@ -59,6 +59,7 @@ class HRSPhaseSetter;
class HeapRegionSetBase VALUE_OBJ_CLASS_SPEC { class HeapRegionSetBase VALUE_OBJ_CLASS_SPEC {
friend class hrs_ext_msg; friend class hrs_ext_msg;
friend class HRSPhaseSetter; friend class HRSPhaseSetter;
friend class VMStructs;
protected: protected:
static size_t calculate_region_num(HeapRegion* hr); static size_t calculate_region_num(HeapRegion* hr);
......
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
nonstatic_field(G1CollectedHeap, _g1_committed, MemRegion) \ nonstatic_field(G1CollectedHeap, _g1_committed, MemRegion) \
nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t) \ nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t) \
nonstatic_field(G1CollectedHeap, _g1mm, G1MonitoringSupport*) \ nonstatic_field(G1CollectedHeap, _g1mm, G1MonitoringSupport*) \
nonstatic_field(G1CollectedHeap, _old_set, HeapRegionSetBase) \
nonstatic_field(G1CollectedHeap, _humongous_set, HeapRegionSetBase) \
\ \
nonstatic_field(G1MonitoringSupport, _eden_committed, size_t) \ nonstatic_field(G1MonitoringSupport, _eden_committed, size_t) \
nonstatic_field(G1MonitoringSupport, _eden_used, size_t) \ nonstatic_field(G1MonitoringSupport, _eden_used, size_t) \
...@@ -47,6 +49,10 @@ ...@@ -47,6 +49,10 @@
nonstatic_field(G1MonitoringSupport, _survivor_used, size_t) \ nonstatic_field(G1MonitoringSupport, _survivor_used, size_t) \
nonstatic_field(G1MonitoringSupport, _old_committed, size_t) \ nonstatic_field(G1MonitoringSupport, _old_committed, size_t) \
nonstatic_field(G1MonitoringSupport, _old_used, size_t) \ nonstatic_field(G1MonitoringSupport, _old_used, size_t) \
\
nonstatic_field(HeapRegionSetBase, _length, size_t) \
nonstatic_field(HeapRegionSetBase, _region_num, size_t) \
nonstatic_field(HeapRegionSetBase, _total_used_bytes, size_t) \
#define VM_TYPES_G1(declare_type, declare_toplevel_type) \ #define VM_TYPES_G1(declare_type, declare_toplevel_type) \
...@@ -55,6 +61,7 @@ ...@@ -55,6 +61,7 @@
\ \
declare_type(HeapRegion, ContiguousSpace) \ declare_type(HeapRegion, ContiguousSpace) \
declare_toplevel_type(HeapRegionSeq) \ declare_toplevel_type(HeapRegionSeq) \
declare_toplevel_type(HeapRegionSetBase) \
declare_toplevel_type(G1MonitoringSupport) \ declare_toplevel_type(G1MonitoringSupport) \
\ \
declare_toplevel_type(G1CollectedHeap*) \ declare_toplevel_type(G1CollectedHeap*) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册