src/share/vm/services/memReporter.hpp

Sat, 29 Sep 2012 06:40:00 -0400

author
coleenp
date
Sat, 29 Sep 2012 06:40:00 -0400
changeset 4142
d8ce2825b193
parent 3900
d2a62e0f25eb
child 4165
fb19af007ffc
permissions
-rw-r--r--

8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
Summary: Capitalize these metadata types (and objArrayKlass)
Reviewed-by: stefank, twisti, kvn

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

mercurial