src/share/vm/services/memReporter.hpp

Fri, 12 Oct 2012 10:49:39 -0700

author
collins
date
Fri, 12 Oct 2012 10:49:39 -0700
changeset 4167
9855b7e559ae
parent 4165
fb19af007ffc
child 4193
716c64bda5ba
permissions
-rw-r--r--

Merge

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
jprovino@4165 33 #if INCLUDE_NMT
jprovino@4165 34
zgu@3900 35 /*
zgu@3900 36 * MemBaselineReporter reports data to this outputer class,
zgu@3900 37 * ReportOutputer is responsible for format, store and redirect
zgu@3900 38 * the data to the final destination.
zgu@3900 39 */
zgu@3900 40 class BaselineOutputer : public StackObj {
zgu@3900 41 public:
zgu@3900 42 // start to report memory usage in specified scale.
zgu@3900 43 // if report_diff = true, the reporter reports baseline comparison
zgu@3900 44 // information.
zgu@3900 45
zgu@3900 46 virtual void start(size_t scale, bool report_diff = false) = 0;
zgu@3900 47 // Done reporting
zgu@3900 48 virtual void done() = 0;
zgu@3900 49
zgu@3900 50 /* report baseline summary information */
zgu@3900 51 virtual void total_usage(size_t total_reserved,
zgu@3900 52 size_t total_committed) = 0;
zgu@3900 53 virtual void num_of_classes(size_t classes) = 0;
zgu@3900 54 virtual void num_of_threads(size_t threads) = 0;
zgu@3900 55
zgu@3900 56 virtual void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) = 0;
zgu@3900 57
zgu@3900 58 /* report baseline summary comparison */
zgu@3900 59 virtual void diff_total_usage(size_t total_reserved,
zgu@3900 60 size_t total_committed,
zgu@3900 61 int reserved_diff,
zgu@3900 62 int committed_diff) = 0;
zgu@3900 63 virtual void diff_num_of_classes(size_t classes, int diff) = 0;
zgu@3900 64 virtual void diff_num_of_threads(size_t threads, int diff) = 0;
zgu@3900 65
zgu@3900 66 virtual void diff_thread_info(size_t stack_reserved, size_t stack_committed,
zgu@3900 67 int stack_reserved_diff, int stack_committed_diff) = 0;
zgu@3900 68
zgu@3900 69
zgu@3900 70 /*
zgu@3900 71 * memory summary by memory types.
zgu@3900 72 * for each memory type, following summaries are reported:
zgu@3900 73 * - reserved amount, committed amount
zgu@3900 74 * - malloc'd amount, malloc count
zgu@3900 75 * - arena amount, arena count
zgu@3900 76 */
zgu@3900 77
zgu@3900 78 // start reporting memory summary by memory type
zgu@3900 79 virtual void start_category_summary() = 0;
zgu@3900 80
zgu@3900 81 virtual void category_summary(MEMFLAGS type, size_t reserved_amt,
zgu@3900 82 size_t committed_amt,
zgu@3900 83 size_t malloc_amt, size_t malloc_count,
zgu@3900 84 size_t arena_amt, size_t arena_count) = 0;
zgu@3900 85
zgu@3900 86 virtual void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt,
zgu@3900 87 size_t cur_committed_amt,
zgu@3900 88 size_t cur_malloc_amt, size_t cur_malloc_count,
zgu@3900 89 size_t cur_arena_amt, size_t cur_arena_count,
zgu@3900 90 int reserved_diff, int committed_diff, int malloc_diff,
zgu@3900 91 int malloc_count_diff, int arena_diff,
zgu@3900 92 int arena_count_diff) = 0;
zgu@3900 93
zgu@3900 94 virtual void done_category_summary() = 0;
zgu@3900 95
zgu@3900 96 /*
zgu@3900 97 * Report callsite information
zgu@3900 98 */
zgu@3900 99 virtual void start_callsite() = 0;
zgu@3900 100 virtual void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count) = 0;
zgu@3900 101 virtual void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt) = 0;
zgu@3900 102
zgu@3900 103 virtual void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count,
zgu@3900 104 int malloc_diff, int malloc_count_diff) = 0;
zgu@3900 105 virtual void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt,
zgu@3900 106 int reserved_diff, int committed_diff) = 0;
zgu@3900 107
zgu@3900 108 virtual void done_callsite() = 0;
zgu@3900 109
zgu@3900 110 // return current scale in "KB", "MB" or "GB"
zgu@3900 111 static const char* memory_unit(size_t scale);
zgu@3900 112 };
zgu@3900 113
zgu@3900 114 /*
zgu@3900 115 * This class reports processed data from a baseline or
zgu@3900 116 * the changes between the two baseline.
zgu@3900 117 */
zgu@3900 118 class BaselineReporter : public StackObj {
zgu@3900 119 private:
zgu@3900 120 BaselineOutputer& _outputer;
zgu@3900 121 size_t _scale;
zgu@3900 122
zgu@3900 123 public:
zgu@3900 124 // construct a reporter that reports memory usage
zgu@3900 125 // in specified scale
zgu@3900 126 BaselineReporter(BaselineOutputer& outputer, size_t scale = K):
zgu@3900 127 _outputer(outputer) {
zgu@3900 128 _scale = scale;
zgu@3900 129 }
zgu@3900 130 virtual void report_baseline(const MemBaseline& baseline, bool summary_only = false);
zgu@3900 131 virtual void diff_baselines(const MemBaseline& cur, const MemBaseline& prev,
zgu@3900 132 bool summary_only = false);
zgu@3900 133
zgu@3900 134 void set_scale(size_t scale);
zgu@3900 135 size_t scale() const { return _scale; }
zgu@3900 136
zgu@3900 137 private:
zgu@3900 138 void report_summaries(const MemBaseline& baseline);
zgu@3900 139 void report_callsites(const MemBaseline& baseline);
zgu@3900 140
zgu@3900 141 void diff_summaries(const MemBaseline& cur, const MemBaseline& prev);
zgu@3900 142 void diff_callsites(const MemBaseline& cur, const MemBaseline& prev);
zgu@3900 143
zgu@3900 144 // calculate memory size in current memory scale
zgu@3900 145 size_t amount_in_current_scale(size_t amt) const;
zgu@3900 146 // diff two unsigned values in current memory scale
zgu@3900 147 int diff_in_current_scale(size_t value1, size_t value2) const;
zgu@3900 148 // diff two unsigned value
zgu@3900 149 int diff(size_t value1, size_t value2) const;
zgu@3900 150 };
zgu@3900 151
zgu@3900 152 /*
zgu@3900 153 * tty output implementation. Native memory tracking
zgu@3900 154 * DCmd uses this outputer.
zgu@3900 155 */
zgu@3900 156 class BaselineTTYOutputer : public BaselineOutputer {
zgu@3900 157 private:
zgu@3900 158 size_t _scale;
zgu@3900 159
zgu@3900 160 size_t _num_of_classes;
zgu@3900 161 size_t _num_of_threads;
zgu@3900 162 size_t _thread_stack_reserved;
zgu@3900 163 size_t _thread_stack_committed;
zgu@3900 164
zgu@3900 165 int _num_of_classes_diff;
zgu@3900 166 int _num_of_threads_diff;
zgu@3900 167 int _thread_stack_reserved_diff;
zgu@3900 168 int _thread_stack_committed_diff;
zgu@3900 169
zgu@3900 170 outputStream* _output;
zgu@3900 171
zgu@3900 172 public:
zgu@3900 173 BaselineTTYOutputer(outputStream* st) {
zgu@3900 174 _scale = K;
zgu@3900 175 _num_of_classes = 0;
zgu@3900 176 _num_of_threads = 0;
zgu@3900 177 _thread_stack_reserved = 0;
zgu@3900 178 _thread_stack_committed = 0;
zgu@3900 179 _num_of_classes_diff = 0;
zgu@3900 180 _num_of_threads_diff = 0;
zgu@3900 181 _thread_stack_reserved_diff = 0;
zgu@3900 182 _thread_stack_committed_diff = 0;
zgu@3900 183 _output = st;
zgu@3900 184 }
zgu@3900 185
zgu@3900 186 // begin reporting memory usage in specified scale
zgu@3900 187 void start(size_t scale, bool report_diff = false);
zgu@3900 188 // done reporting
zgu@3900 189 void done();
zgu@3900 190
zgu@3900 191 // total memory usage
zgu@3900 192 void total_usage(size_t total_reserved,
zgu@3900 193 size_t total_committed);
zgu@3900 194 // report total loaded classes
zgu@3900 195 void num_of_classes(size_t classes) {
zgu@3900 196 _num_of_classes = classes;
zgu@3900 197 }
zgu@3900 198
zgu@3900 199 void num_of_threads(size_t threads) {
zgu@3900 200 _num_of_threads = threads;
zgu@3900 201 }
zgu@3900 202
zgu@3900 203 void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) {
zgu@3900 204 _thread_stack_reserved = stack_reserved_amt;
zgu@3900 205 _thread_stack_committed = stack_committed_amt;
zgu@3900 206 }
zgu@3900 207
zgu@3900 208 void diff_total_usage(size_t total_reserved,
zgu@3900 209 size_t total_committed,
zgu@3900 210 int reserved_diff,
zgu@3900 211 int committed_diff);
zgu@3900 212
zgu@3900 213 void diff_num_of_classes(size_t classes, int diff) {
zgu@3900 214 _num_of_classes = classes;
zgu@3900 215 _num_of_classes_diff = diff;
zgu@3900 216 }
zgu@3900 217
zgu@3900 218 void diff_num_of_threads(size_t threads, int diff) {
zgu@3900 219 _num_of_threads = threads;
zgu@3900 220 _num_of_threads_diff = diff;
zgu@3900 221 }
zgu@3900 222
zgu@3900 223 void diff_thread_info(size_t stack_reserved_amt, size_t stack_committed_amt,
zgu@3900 224 int stack_reserved_diff, int stack_committed_diff) {
zgu@3900 225 _thread_stack_reserved = stack_reserved_amt;
zgu@3900 226 _thread_stack_committed = stack_committed_amt;
zgu@3900 227 _thread_stack_reserved_diff = stack_reserved_diff;
zgu@3900 228 _thread_stack_committed_diff = stack_committed_diff;
zgu@3900 229 }
zgu@3900 230
zgu@3900 231 /*
zgu@3900 232 * Report memory summary categoriuzed by memory types.
zgu@3900 233 * For each memory type, following summaries are reported:
zgu@3900 234 * - reserved amount, committed amount
zgu@3900 235 * - malloc-ed amount, malloc count
zgu@3900 236 * - arena amount, arena count
zgu@3900 237 */
zgu@3900 238 // start reporting memory summary by memory type
zgu@3900 239 void start_category_summary();
zgu@3900 240 void category_summary(MEMFLAGS type, size_t reserved_amt, size_t committed_amt,
zgu@3900 241 size_t malloc_amt, size_t malloc_count,
zgu@3900 242 size_t arena_amt, size_t arena_count);
zgu@3900 243
zgu@3900 244 void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt,
zgu@3900 245 size_t cur_committed_amt,
zgu@3900 246 size_t cur_malloc_amt, size_t cur_malloc_count,
zgu@3900 247 size_t cur_arena_amt, size_t cur_arena_count,
zgu@3900 248 int reserved_diff, int committed_diff, int malloc_diff,
zgu@3900 249 int malloc_count_diff, int arena_diff,
zgu@3900 250 int arena_count_diff);
zgu@3900 251
zgu@3900 252 void done_category_summary();
zgu@3900 253
zgu@3900 254 /*
zgu@3900 255 * Report callsite information
zgu@3900 256 */
zgu@3900 257 void start_callsite();
zgu@3900 258 void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count);
zgu@3900 259 void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt);
zgu@3900 260
zgu@3900 261 void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count,
zgu@3900 262 int malloc_diff, int malloc_count_diff);
zgu@3900 263 void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt,
zgu@3900 264 int reserved_diff, int committed_diff);
zgu@3900 265
zgu@3900 266 void done_callsite();
zgu@3900 267 };
zgu@3900 268
zgu@3900 269
jprovino@4165 270 #endif // INCLUDE_NMT
jprovino@4165 271
zgu@3900 272 #endif // SHARE_VM_SERVICES_MEM_REPORTER_HPP

mercurial