annotate src/share/vm/interpreter/bytecodeHistogram.cpp @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents f95d63e2154a
children
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 "interpreter/bytecodeHistogram.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "utilities/growableArray.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // ------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Non-product code
a61af66fc99e Initial load
duke
parents:
diff changeset
33 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Implementation of BytecodeCounter
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 int BytecodeCounter::_counter_value = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 jlong BytecodeCounter::_reset_time = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 void BytecodeCounter::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 _counter_value = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 _reset_time = os::elapsed_counter();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 double BytecodeCounter::elapsed_time() {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 return (double)(os::elapsed_counter() - _reset_time) / (double)os::elapsed_frequency();
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 double BytecodeCounter::frequency() {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return (double)counter_value() / elapsed_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 void BytecodeCounter::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
59 "%d bytecodes executed in %.1fs (%.3fMHz)",
a61af66fc99e Initial load
duke
parents:
diff changeset
60 counter_value(),
a61af66fc99e Initial load
duke
parents:
diff changeset
61 elapsed_time(),
a61af66fc99e Initial load
duke
parents:
diff changeset
62 frequency() / 1000000.0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 );
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Helper class for sorting
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 class HistoEntry: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 int _index;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int _count;
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
75 HistoEntry(int index, int count) { _index = index; _count = count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 int index() const { return _index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 int count() const { return _count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static int compare(HistoEntry** x, HistoEntry** y) { return (*x)->count() - (*y)->count(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 };
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Helper functions
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 static GrowableArray<HistoEntry*>* sorted_array(int* array, int length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 GrowableArray<HistoEntry*>* a = new GrowableArray<HistoEntry*>(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 int i = length;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 while (i-- > 0) a->append(new HistoEntry(i, array[i]));
a61af66fc99e Initial load
duke
parents:
diff changeset
89 a->sort(HistoEntry::compare);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return a;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 static int total_count(GrowableArray<HistoEntry*>* profile) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 int sum = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int i = profile->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
97 while (i-- > 0) sum += profile->at(i)->count();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return sum;
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 static const char* name_for(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return Bytecodes::is_defined(i) ? Bytecodes::name(Bytecodes::cast(i)) : "xxxunusedxxx";
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 // Implementation of BytecodeHistogram
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 int BytecodeHistogram::_counters[Bytecodes::number_of_codes];
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void BytecodeHistogram::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 int i = Bytecodes::number_of_codes;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 while (i-- > 0) _counters[i] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 void BytecodeHistogram::print(float cutoff) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 GrowableArray<HistoEntry*>* profile = sorted_array(_counters, Bytecodes::number_of_codes);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // print profile
a61af66fc99e Initial load
duke
parents:
diff changeset
122 int tot = total_count(profile);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int abs_sum = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 tty->cr(); //0123456789012345678901234567890123456789012345678901234567890123456789
a61af66fc99e Initial load
duke
parents:
diff changeset
125 tty->print_cr("Histogram of %d executed bytecodes:", tot);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 tty->print_cr(" absolute relative code name");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 tty->print_cr("----------------------------------------------------------------------");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 int i = profile->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 while (i-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 HistoEntry* e = profile->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 int abs = e->count();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 float rel = abs * 100.0F / tot;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 if (cutoff <= rel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 tty->print_cr("%10d %7.2f%% %02x %s", abs, rel, e->index(), name_for(e->index()));
a61af66fc99e Initial load
duke
parents:
diff changeset
136 abs_sum += abs;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 tty->print_cr("----------------------------------------------------------------------");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 float rel_sum = abs_sum * 100.0F / tot;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 tty->print_cr("%10d %7.2f%% (cutoff = %.2f%%)", abs_sum, rel_sum, cutoff);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // Implementation of BytecodePairHistogram
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 int BytecodePairHistogram::_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 int BytecodePairHistogram::_counters[BytecodePairHistogram::number_of_pairs];
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 void BytecodePairHistogram::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 _index = Bytecodes::_nop << log2_number_of_codes;
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 int i = number_of_pairs;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 while (i-- > 0) _counters[i] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void BytecodePairHistogram::print(float cutoff) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 GrowableArray<HistoEntry*>* profile = sorted_array(_counters, number_of_pairs);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // print profile
a61af66fc99e Initial load
duke
parents:
diff changeset
164 int tot = total_count(profile);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 int abs_sum = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 tty->cr(); //0123456789012345678901234567890123456789012345678901234567890123456789
a61af66fc99e Initial load
duke
parents:
diff changeset
167 tty->print_cr("Histogram of %d executed bytecode pairs:", tot);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
169 tty->print_cr(" absolute relative codes 1st bytecode 2nd bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 tty->print_cr("----------------------------------------------------------------------");
a61af66fc99e Initial load
duke
parents:
diff changeset
171 int i = profile->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 while (i-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 HistoEntry* e = profile->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 int abs = e->count();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 float rel = abs * 100.0F / tot;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (cutoff <= rel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 int c1 = e->index() % number_of_codes;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 int c2 = e->index() / number_of_codes;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 tty->print_cr("%10d %6.3f%% %02x %02x %-19s %s", abs, rel, c1, c2, name_for(c1), name_for(c2));
a61af66fc99e Initial load
duke
parents:
diff changeset
180 abs_sum += abs;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 tty->print_cr("----------------------------------------------------------------------");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 float rel_sum = abs_sum * 100.0F / tot;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 tty->print_cr("%10d %6.3f%% (cutoff = %.3f%%)", abs_sum, rel_sum, cutoff);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 #endif