annotate src/share/vm/runtime/aprofiler.cpp @ 2368:dde920245681

6896099: Integrate CMS heap ergo with default heap sizing ergo 6627787: CMS: JVM refuses to start up with -Xms16m -Xmx16m 7000125: CMS: Anti-monotone young gen sizing with respect to maximum whole heap size specification 7027529: CMS: retire CMSUseOldDefaults flag Summary: Simplify CMS heap sizing code, relying on ergonomic initial sizing consistent with other collectors for the most part, controlling only young gen sizing to rein in pause times. Make CMS young gen sizing default statically cpu-dependant. Remove inconsistencies wrt generation sizing and policy code, allowing for the fixing for 6627787 and 7000125. For 7027529, retire the flag CMSUseOldDefaults which had been introduced as a bridge from JDK 5 to JDK 6 a number of years ago. Reviewed-by: brutisso, poonam
author ysr
date Wed, 16 Mar 2011 10:37:08 -0700
parents f95d63e2154a
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_interface/collectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/permGen.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/space.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/oop.inline2.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/aprofiler.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 bool AllocationProfiler::_active = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 GrowableArray<klassOop>* AllocationProfiler::_print_array = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class AllocProfClosure : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 Klass* k = obj->blueprint();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 k->set_alloc_count(k->alloc_count() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 k->set_alloc_size(k->alloc_size() + obj->size());
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 };
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 class AllocProfResetClosure : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 Klass* k = Klass::cast(klassOop(obj));
a61af66fc99e Initial load
duke
parents:
diff changeset
57 k->set_alloc_count(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 k->set_alloc_size(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 };
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void AllocationProfiler::iterate_since_last_gc() {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 if (is_active()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 AllocProfClosure blk;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 GenCollectedHeap* heap = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 heap->object_iterate_since_last_GC(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void AllocationProfiler::engage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _active = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 void AllocationProfiler::disengage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _active = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void AllocationProfiler::add_class_to_array(klassOop k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 _print_array->append(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 void AllocationProfiler::add_classes_to_array(klassOop k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Iterate over klass and all array klasses for klass
a61af66fc99e Initial load
duke
parents:
diff changeset
92 k->klass_part()->with_array_klasses_do(&AllocationProfiler::add_class_to_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int AllocationProfiler::compare_classes(klassOop* k1, klassOop* k2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Sort by total allocation size
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return (*k2)->klass_part()->alloc_size() - (*k1)->klass_part()->alloc_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 int AllocationProfiler::average(size_t alloc_size, int alloc_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return (int) ((double) (alloc_size * BytesPerWord) / MAX2(alloc_count, 1) + 0.5);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 void AllocationProfiler::sort_and_print_array(size_t cutoff) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _print_array->sort(&AllocationProfiler::compare_classes);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 tty->print_cr("________________Size"
a61af66fc99e Initial load
duke
parents:
diff changeset
110 "__Instances"
a61af66fc99e Initial load
duke
parents:
diff changeset
111 "__Average"
a61af66fc99e Initial load
duke
parents:
diff changeset
112 "__Class________________");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 size_t total_alloc_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 int total_alloc_count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 for (int index = 0; index < _print_array->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 klassOop k = _print_array->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 size_t alloc_size = k->klass_part()->alloc_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (alloc_size > cutoff) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 int alloc_count = k->klass_part()->alloc_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 #ifdef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
121 const char* name = k->klass_part()->external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
123 const char* name = k->klass_part()->internal_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
125 tty->print_cr("%20u %10u %8u %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
126 alloc_size * BytesPerWord,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 alloc_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 average(alloc_size, alloc_count),
a61af66fc99e Initial load
duke
parents:
diff changeset
129 name);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 total_alloc_size += alloc_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 total_alloc_count += alloc_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 tty->print_cr("%20u %10u %8u --total--",
a61af66fc99e Initial load
duke
parents:
diff changeset
135 total_alloc_size * BytesPerWord,
a61af66fc99e Initial load
duke
parents:
diff changeset
136 total_alloc_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
137 average(total_alloc_size, total_alloc_count));
a61af66fc99e Initial load
duke
parents:
diff changeset
138 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 void AllocationProfiler::print(size_t cutoff) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 assert(!is_active(), "AllocationProfiler cannot be active while printing profile");
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 tty->print_cr("Allocation profile (sizes in bytes, cutoff = %ld bytes):", cutoff * BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Print regular instance klasses and basic type array klasses
a61af66fc99e Initial load
duke
parents:
diff changeset
151 _print_array = new GrowableArray<klassOop>(SystemDictionary::number_of_classes()*2);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 SystemDictionary::classes_do(&add_classes_to_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 Universe::basic_type_classes_do(&add_classes_to_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 sort_and_print_array(cutoff);
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
157 tty->print_cr("Allocation profile for system classes (sizes in bytes, cutoff = %d bytes):", cutoff * BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Print system klasses (methods, symbols, constant pools, etc.)
a61af66fc99e Initial load
duke
parents:
diff changeset
161 _print_array = new GrowableArray<klassOop>(64);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 Universe::system_classes_do(&add_classes_to_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 sort_and_print_array(cutoff);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 tty->print_cr("Permanent generation dump (sizes in bytes, cutoff = %d bytes):", cutoff * BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 AllocProfResetClosure resetblk;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 Universe::heap()->permanent_object_iterate(&resetblk);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 AllocProfClosure blk;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 Universe::heap()->permanent_object_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 _print_array = new GrowableArray<klassOop>(SystemDictionary::number_of_classes()*2);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 SystemDictionary::classes_do(&add_classes_to_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 Universe::basic_type_classes_do(&add_classes_to_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Universe::system_classes_do(&add_classes_to_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 sort_and_print_array(cutoff);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }