Mercurial > hg > truffle
annotate src/share/vm/services/memReporter.hpp @ 14702:d4dd5204c0aa
Merge
author | ehelin |
---|---|
date | Fri, 14 Mar 2014 13:27:18 +0100 |
parents | de6a9e811145 |
children | 4ca6dc0799b6 833b0f92429a |
rev | line source |
---|---|
6197 | 1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
8001
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
6197 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_SERVICES_MEM_REPORTER_HPP | |
26 #define SHARE_VM_SERVICES_MEM_REPORTER_HPP | |
27 | |
28 #include "runtime/mutexLocker.hpp" | |
29 #include "services/memBaseline.hpp" | |
30 #include "services/memTracker.hpp" | |
31 #include "utilities/ostream.hpp" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7440
diff
changeset
|
32 #include "utilities/macros.hpp" |
6197 | 33 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
34 #if INCLUDE_NMT |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
35 |
6197 | 36 /* |
37 * MemBaselineReporter reports data to this outputer class, | |
38 * ReportOutputer is responsible for format, store and redirect | |
39 * the data to the final destination. | |
40 */ | |
41 class BaselineOutputer : public StackObj { | |
42 public: | |
43 // start to report memory usage in specified scale. | |
44 // if report_diff = true, the reporter reports baseline comparison | |
45 // information. | |
46 | |
47 virtual void start(size_t scale, bool report_diff = false) = 0; | |
48 // Done reporting | |
49 virtual void done() = 0; | |
50 | |
51 /* report baseline summary information */ | |
52 virtual void total_usage(size_t total_reserved, | |
53 size_t total_committed) = 0; | |
54 virtual void num_of_classes(size_t classes) = 0; | |
55 virtual void num_of_threads(size_t threads) = 0; | |
56 | |
57 virtual void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) = 0; | |
58 | |
59 /* report baseline summary comparison */ | |
60 virtual void diff_total_usage(size_t total_reserved, | |
61 size_t total_committed, | |
62 int reserved_diff, | |
63 int committed_diff) = 0; | |
64 virtual void diff_num_of_classes(size_t classes, int diff) = 0; | |
65 virtual void diff_num_of_threads(size_t threads, int diff) = 0; | |
66 | |
67 virtual void diff_thread_info(size_t stack_reserved, size_t stack_committed, | |
68 int stack_reserved_diff, int stack_committed_diff) = 0; | |
69 | |
70 | |
71 /* | |
72 * memory summary by memory types. | |
73 * for each memory type, following summaries are reported: | |
74 * - reserved amount, committed amount | |
75 * - malloc'd amount, malloc count | |
76 * - arena amount, arena count | |
77 */ | |
78 | |
79 // start reporting memory summary by memory type | |
80 virtual void start_category_summary() = 0; | |
81 | |
82 virtual void category_summary(MEMFLAGS type, size_t reserved_amt, | |
83 size_t committed_amt, | |
84 size_t malloc_amt, size_t malloc_count, | |
85 size_t arena_amt, size_t arena_count) = 0; | |
86 | |
87 virtual void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt, | |
88 size_t cur_committed_amt, | |
89 size_t cur_malloc_amt, size_t cur_malloc_count, | |
90 size_t cur_arena_amt, size_t cur_arena_count, | |
91 int reserved_diff, int committed_diff, int malloc_diff, | |
92 int malloc_count_diff, int arena_diff, | |
93 int arena_count_diff) = 0; | |
94 | |
95 virtual void done_category_summary() = 0; | |
96 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
97 virtual void start_virtual_memory_map() = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
98 virtual void reserved_memory_region(MEMFLAGS type, address base, address end, size_t size, address pc) = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
99 virtual void committed_memory_region(address base, address end, size_t size, address pc) = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
100 virtual void done_virtual_memory_map() = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
101 |
6197 | 102 /* |
103 * Report callsite information | |
104 */ | |
105 virtual void start_callsite() = 0; | |
106 virtual void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count) = 0; | |
107 virtual void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt) = 0; | |
108 | |
109 virtual void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count, | |
110 int malloc_diff, int malloc_count_diff) = 0; | |
111 virtual void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt, | |
112 int reserved_diff, int committed_diff) = 0; | |
113 | |
114 virtual void done_callsite() = 0; | |
115 | |
116 // return current scale in "KB", "MB" or "GB" | |
117 static const char* memory_unit(size_t scale); | |
118 }; | |
119 | |
120 /* | |
121 * This class reports processed data from a baseline or | |
122 * the changes between the two baseline. | |
123 */ | |
124 class BaselineReporter : public StackObj { | |
125 private: | |
126 BaselineOutputer& _outputer; | |
127 size_t _scale; | |
128 | |
129 public: | |
130 // construct a reporter that reports memory usage | |
131 // in specified scale | |
132 BaselineReporter(BaselineOutputer& outputer, size_t scale = K): | |
133 _outputer(outputer) { | |
134 _scale = scale; | |
135 } | |
136 virtual void report_baseline(const MemBaseline& baseline, bool summary_only = false); | |
137 virtual void diff_baselines(const MemBaseline& cur, const MemBaseline& prev, | |
138 bool summary_only = false); | |
139 | |
140 void set_scale(size_t scale); | |
141 size_t scale() const { return _scale; } | |
142 | |
143 private: | |
144 void report_summaries(const MemBaseline& baseline); | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
145 void report_virtual_memory_map(const MemBaseline& baseline); |
6197 | 146 void report_callsites(const MemBaseline& baseline); |
147 | |
148 void diff_summaries(const MemBaseline& cur, const MemBaseline& prev); | |
149 void diff_callsites(const MemBaseline& cur, const MemBaseline& prev); | |
150 | |
151 // calculate memory size in current memory scale | |
152 size_t amount_in_current_scale(size_t amt) const; | |
153 // diff two unsigned values in current memory scale | |
154 int diff_in_current_scale(size_t value1, size_t value2) const; | |
155 // diff two unsigned value | |
156 int diff(size_t value1, size_t value2) const; | |
157 }; | |
158 | |
159 /* | |
160 * tty output implementation. Native memory tracking | |
161 * DCmd uses this outputer. | |
162 */ | |
163 class BaselineTTYOutputer : public BaselineOutputer { | |
164 private: | |
165 size_t _scale; | |
166 | |
167 size_t _num_of_classes; | |
168 size_t _num_of_threads; | |
169 size_t _thread_stack_reserved; | |
170 size_t _thread_stack_committed; | |
171 | |
172 int _num_of_classes_diff; | |
173 int _num_of_threads_diff; | |
174 int _thread_stack_reserved_diff; | |
175 int _thread_stack_committed_diff; | |
176 | |
177 outputStream* _output; | |
178 | |
179 public: | |
180 BaselineTTYOutputer(outputStream* st) { | |
181 _scale = K; | |
182 _num_of_classes = 0; | |
183 _num_of_threads = 0; | |
184 _thread_stack_reserved = 0; | |
185 _thread_stack_committed = 0; | |
186 _num_of_classes_diff = 0; | |
187 _num_of_threads_diff = 0; | |
188 _thread_stack_reserved_diff = 0; | |
189 _thread_stack_committed_diff = 0; | |
190 _output = st; | |
191 } | |
192 | |
193 // begin reporting memory usage in specified scale | |
194 void start(size_t scale, bool report_diff = false); | |
195 // done reporting | |
196 void done(); | |
197 | |
198 // total memory usage | |
199 void total_usage(size_t total_reserved, | |
200 size_t total_committed); | |
201 // report total loaded classes | |
202 void num_of_classes(size_t classes) { | |
203 _num_of_classes = classes; | |
204 } | |
205 | |
206 void num_of_threads(size_t threads) { | |
207 _num_of_threads = threads; | |
208 } | |
209 | |
210 void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) { | |
211 _thread_stack_reserved = stack_reserved_amt; | |
212 _thread_stack_committed = stack_committed_amt; | |
213 } | |
214 | |
215 void diff_total_usage(size_t total_reserved, | |
216 size_t total_committed, | |
217 int reserved_diff, | |
218 int committed_diff); | |
219 | |
220 void diff_num_of_classes(size_t classes, int diff) { | |
221 _num_of_classes = classes; | |
222 _num_of_classes_diff = diff; | |
223 } | |
224 | |
225 void diff_num_of_threads(size_t threads, int diff) { | |
226 _num_of_threads = threads; | |
227 _num_of_threads_diff = diff; | |
228 } | |
229 | |
230 void diff_thread_info(size_t stack_reserved_amt, size_t stack_committed_amt, | |
231 int stack_reserved_diff, int stack_committed_diff) { | |
232 _thread_stack_reserved = stack_reserved_amt; | |
233 _thread_stack_committed = stack_committed_amt; | |
234 _thread_stack_reserved_diff = stack_reserved_diff; | |
235 _thread_stack_committed_diff = stack_committed_diff; | |
236 } | |
237 | |
238 /* | |
239 * Report memory summary categoriuzed by memory types. | |
240 * For each memory type, following summaries are reported: | |
241 * - reserved amount, committed amount | |
242 * - malloc-ed amount, malloc count | |
243 * - arena amount, arena count | |
244 */ | |
245 // start reporting memory summary by memory type | |
246 void start_category_summary(); | |
247 void category_summary(MEMFLAGS type, size_t reserved_amt, size_t committed_amt, | |
248 size_t malloc_amt, size_t malloc_count, | |
249 size_t arena_amt, size_t arena_count); | |
250 | |
251 void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt, | |
252 size_t cur_committed_amt, | |
253 size_t cur_malloc_amt, size_t cur_malloc_count, | |
254 size_t cur_arena_amt, size_t cur_arena_count, | |
255 int reserved_diff, int committed_diff, int malloc_diff, | |
256 int malloc_count_diff, int arena_diff, | |
257 int arena_count_diff); | |
258 | |
259 void done_category_summary(); | |
260 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
261 // virtual memory map |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
262 void start_virtual_memory_map(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
263 void reserved_memory_region(MEMFLAGS type, address base, address end, size_t size, address pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
264 void committed_memory_region(address base, address end, size_t size, address pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
265 void done_virtual_memory_map(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
266 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
267 |
6197 | 268 /* |
269 * Report callsite information | |
270 */ | |
271 void start_callsite(); | |
272 void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count); | |
273 void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt); | |
274 | |
275 void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count, | |
276 int malloc_diff, int malloc_count_diff); | |
277 void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt, | |
278 int reserved_diff, int committed_diff); | |
279 | |
280 void done_callsite(); | |
281 }; | |
282 | |
283 | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
284 #endif // INCLUDE_NMT |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
285 |
6197 | 286 #endif // SHARE_VM_SERVICES_MEM_REPORTER_HPP |