Sun, 03 Feb 2013 22:28:08 +0400
8002048: Protocol to discovery of manageable Java processes on a network
Summary: Introduce a protocol to discover manageble Java instances across a network subnet, JDP
Reviewed-by: sla, dfuchs
zgu@3900 | 1 | /* |
katleman@4376 | 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 | #include "precompiled.hpp" |
zgu@3900 | 25 | #include "classfile/systemDictionary.hpp" |
zgu@3900 | 26 | #include "runtime/os.hpp" |
zgu@3900 | 27 | #include "services/memReporter.hpp" |
zgu@3900 | 28 | #include "services/memPtrArray.hpp" |
zgu@3900 | 29 | #include "services/memTracker.hpp" |
zgu@3900 | 30 | |
zgu@3900 | 31 | const char* BaselineOutputer::memory_unit(size_t scale) { |
zgu@3900 | 32 | switch(scale) { |
zgu@3900 | 33 | case K: return "KB"; |
zgu@3900 | 34 | case M: return "MB"; |
zgu@3900 | 35 | case G: return "GB"; |
zgu@3900 | 36 | } |
zgu@3900 | 37 | ShouldNotReachHere(); |
zgu@3900 | 38 | return NULL; |
zgu@3900 | 39 | } |
zgu@3900 | 40 | |
zgu@3900 | 41 | |
zgu@3900 | 42 | void BaselineReporter::report_baseline(const MemBaseline& baseline, bool summary_only) { |
zgu@3900 | 43 | assert(MemTracker::is_on(), "Native memory tracking is off"); |
zgu@3900 | 44 | _outputer.start(scale()); |
zgu@3900 | 45 | _outputer.total_usage( |
zgu@3900 | 46 | amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_reserved_amount()), |
zgu@3900 | 47 | amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_committed_amount())); |
zgu@3900 | 48 | |
zgu@3900 | 49 | _outputer.num_of_classes(baseline.number_of_classes()); |
zgu@3900 | 50 | _outputer.num_of_threads(baseline.number_of_threads()); |
zgu@3900 | 51 | |
zgu@3900 | 52 | report_summaries(baseline); |
zgu@3900 | 53 | if (!summary_only && MemTracker::track_callsite()) { |
zgu@4193 | 54 | report_virtual_memory_map(baseline); |
zgu@3900 | 55 | report_callsites(baseline); |
zgu@3900 | 56 | } |
zgu@3900 | 57 | _outputer.done(); |
zgu@3900 | 58 | } |
zgu@3900 | 59 | |
zgu@3900 | 60 | void BaselineReporter::report_summaries(const MemBaseline& baseline) { |
zgu@3900 | 61 | _outputer.start_category_summary(); |
zgu@3900 | 62 | MEMFLAGS type; |
zgu@3900 | 63 | |
zgu@3900 | 64 | for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { |
zgu@3900 | 65 | type = MemBaseline::MemType2NameMap[index]._flag; |
zgu@3900 | 66 | _outputer.category_summary(type, |
zgu@3900 | 67 | amount_in_current_scale(baseline.reserved_amount(type)), |
zgu@3900 | 68 | amount_in_current_scale(baseline.committed_amount(type)), |
zgu@3900 | 69 | amount_in_current_scale(baseline.malloc_amount(type)), |
zgu@3900 | 70 | baseline.malloc_count(type), |
zgu@3900 | 71 | amount_in_current_scale(baseline.arena_amount(type)), |
zgu@3900 | 72 | baseline.arena_count(type)); |
zgu@3900 | 73 | } |
zgu@3900 | 74 | |
zgu@3900 | 75 | _outputer.done_category_summary(); |
zgu@3900 | 76 | } |
zgu@3900 | 77 | |
zgu@4193 | 78 | void BaselineReporter::report_virtual_memory_map(const MemBaseline& baseline) { |
zgu@4193 | 79 | _outputer.start_virtual_memory_map(); |
zgu@4193 | 80 | MemBaseline* pBL = const_cast<MemBaseline*>(&baseline); |
zgu@4193 | 81 | MemPointerArrayIteratorImpl itr = MemPointerArrayIteratorImpl(pBL->_vm_map); |
zgu@4193 | 82 | VMMemRegionEx* rgn = (VMMemRegionEx*)itr.current(); |
zgu@4193 | 83 | while (rgn != NULL) { |
zgu@4193 | 84 | if (rgn->is_reserved_region()) { |
zgu@4193 | 85 | _outputer.reserved_memory_region(FLAGS_TO_MEMORY_TYPE(rgn->flags()), |
zgu@4193 | 86 | rgn->base(), rgn->base() + rgn->size(), amount_in_current_scale(rgn->size()), rgn->pc()); |
zgu@4193 | 87 | } else { |
zgu@4193 | 88 | _outputer.committed_memory_region(rgn->base(), rgn->base() + rgn->size(), |
zgu@4193 | 89 | amount_in_current_scale(rgn->size()), rgn->pc()); |
zgu@4193 | 90 | } |
zgu@4193 | 91 | rgn = (VMMemRegionEx*)itr.next(); |
zgu@4193 | 92 | } |
zgu@4193 | 93 | |
zgu@4193 | 94 | _outputer.done_virtual_memory_map(); |
zgu@4193 | 95 | } |
zgu@4193 | 96 | |
zgu@3900 | 97 | void BaselineReporter::report_callsites(const MemBaseline& baseline) { |
zgu@3900 | 98 | _outputer.start_callsite(); |
zgu@3900 | 99 | MemBaseline* pBL = const_cast<MemBaseline*>(&baseline); |
zgu@3900 | 100 | |
zgu@3900 | 101 | pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_size); |
zgu@3900 | 102 | pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_size); |
zgu@3900 | 103 | |
zgu@3900 | 104 | // walk malloc callsites |
zgu@3900 | 105 | MemPointerArrayIteratorImpl malloc_itr(pBL->_malloc_cs); |
zgu@3900 | 106 | MallocCallsitePointer* malloc_callsite = |
zgu@3900 | 107 | (MallocCallsitePointer*)malloc_itr.current(); |
zgu@3900 | 108 | while (malloc_callsite != NULL) { |
zgu@3900 | 109 | _outputer.malloc_callsite(malloc_callsite->addr(), |
zgu@3900 | 110 | amount_in_current_scale(malloc_callsite->amount()), malloc_callsite->count()); |
zgu@3900 | 111 | malloc_callsite = (MallocCallsitePointer*)malloc_itr.next(); |
zgu@3900 | 112 | } |
zgu@3900 | 113 | |
zgu@3900 | 114 | // walk virtual memory callsite |
zgu@3900 | 115 | MemPointerArrayIteratorImpl vm_itr(pBL->_vm_cs); |
zgu@3900 | 116 | VMCallsitePointer* vm_callsite = (VMCallsitePointer*)vm_itr.current(); |
zgu@3900 | 117 | while (vm_callsite != NULL) { |
zgu@3900 | 118 | _outputer.virtual_memory_callsite(vm_callsite->addr(), |
zgu@3900 | 119 | amount_in_current_scale(vm_callsite->reserved_amount()), |
zgu@3900 | 120 | amount_in_current_scale(vm_callsite->committed_amount())); |
zgu@3900 | 121 | vm_callsite = (VMCallsitePointer*)vm_itr.next(); |
zgu@3900 | 122 | } |
zgu@3900 | 123 | pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_pc); |
zgu@3900 | 124 | pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_pc); |
zgu@3900 | 125 | _outputer.done_callsite(); |
zgu@3900 | 126 | } |
zgu@3900 | 127 | |
zgu@3900 | 128 | void BaselineReporter::diff_baselines(const MemBaseline& cur, const MemBaseline& prev, |
zgu@3900 | 129 | bool summary_only) { |
zgu@3900 | 130 | assert(MemTracker::is_on(), "Native memory tracking is off"); |
zgu@3900 | 131 | _outputer.start(scale()); |
zgu@3900 | 132 | size_t total_reserved = cur.total_malloc_amount() + cur.total_reserved_amount(); |
zgu@3900 | 133 | size_t total_committed = cur.total_malloc_amount() + cur.total_committed_amount(); |
zgu@3900 | 134 | |
zgu@3900 | 135 | _outputer.diff_total_usage( |
zgu@3900 | 136 | amount_in_current_scale(total_reserved), amount_in_current_scale(total_committed), |
zgu@3900 | 137 | diff_in_current_scale(total_reserved, (prev.total_malloc_amount() + prev.total_reserved_amount())), |
zgu@3900 | 138 | diff_in_current_scale(total_committed, (prev.total_committed_amount() + prev.total_malloc_amount()))); |
zgu@3900 | 139 | |
zgu@3900 | 140 | _outputer.diff_num_of_classes(cur.number_of_classes(), |
zgu@3900 | 141 | diff(cur.number_of_classes(), prev.number_of_classes())); |
zgu@3900 | 142 | _outputer.diff_num_of_threads(cur.number_of_threads(), |
zgu@3900 | 143 | diff(cur.number_of_threads(), prev.number_of_threads())); |
zgu@3900 | 144 | |
zgu@3900 | 145 | diff_summaries(cur, prev); |
zgu@3900 | 146 | if (!summary_only && MemTracker::track_callsite()) { |
zgu@3900 | 147 | diff_callsites(cur, prev); |
zgu@3900 | 148 | } |
zgu@3900 | 149 | _outputer.done(); |
zgu@3900 | 150 | } |
zgu@3900 | 151 | |
zgu@3900 | 152 | void BaselineReporter::diff_summaries(const MemBaseline& cur, const MemBaseline& prev) { |
zgu@3900 | 153 | _outputer.start_category_summary(); |
zgu@3900 | 154 | MEMFLAGS type; |
zgu@3900 | 155 | |
zgu@3900 | 156 | for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { |
zgu@3900 | 157 | type = MemBaseline::MemType2NameMap[index]._flag; |
zgu@3900 | 158 | _outputer.diff_category_summary(type, |
zgu@3900 | 159 | amount_in_current_scale(cur.reserved_amount(type)), |
zgu@3900 | 160 | amount_in_current_scale(cur.committed_amount(type)), |
zgu@3900 | 161 | amount_in_current_scale(cur.malloc_amount(type)), |
zgu@3900 | 162 | cur.malloc_count(type), |
zgu@3900 | 163 | amount_in_current_scale(cur.arena_amount(type)), |
zgu@3900 | 164 | cur.arena_count(type), |
zgu@3900 | 165 | diff_in_current_scale(cur.reserved_amount(type), prev.reserved_amount(type)), |
zgu@3900 | 166 | diff_in_current_scale(cur.committed_amount(type), prev.committed_amount(type)), |
zgu@3900 | 167 | diff_in_current_scale(cur.malloc_amount(type), prev.malloc_amount(type)), |
zgu@3900 | 168 | diff(cur.malloc_count(type), prev.malloc_count(type)), |
zgu@3900 | 169 | diff_in_current_scale(cur.arena_amount(type), prev.arena_amount(type)), |
zgu@3900 | 170 | diff(cur.arena_count(type), prev.arena_count(type))); |
zgu@3900 | 171 | } |
zgu@3900 | 172 | |
zgu@3900 | 173 | _outputer.done_category_summary(); |
zgu@3900 | 174 | } |
zgu@3900 | 175 | |
zgu@3900 | 176 | void BaselineReporter::diff_callsites(const MemBaseline& cur, const MemBaseline& prev) { |
zgu@3900 | 177 | _outputer.start_callsite(); |
zgu@3900 | 178 | MemBaseline* pBL_cur = const_cast<MemBaseline*>(&cur); |
zgu@3900 | 179 | MemBaseline* pBL_prev = const_cast<MemBaseline*>(&prev); |
zgu@3900 | 180 | |
zgu@3900 | 181 | // walk malloc callsites |
zgu@3900 | 182 | MemPointerArrayIteratorImpl cur_malloc_itr(pBL_cur->_malloc_cs); |
zgu@3900 | 183 | MemPointerArrayIteratorImpl prev_malloc_itr(pBL_prev->_malloc_cs); |
zgu@3900 | 184 | |
zgu@3900 | 185 | MallocCallsitePointer* cur_malloc_callsite = |
zgu@3900 | 186 | (MallocCallsitePointer*)cur_malloc_itr.current(); |
zgu@3900 | 187 | MallocCallsitePointer* prev_malloc_callsite = |
zgu@3900 | 188 | (MallocCallsitePointer*)prev_malloc_itr.current(); |
zgu@3900 | 189 | |
zgu@3900 | 190 | while (cur_malloc_callsite != NULL || prev_malloc_callsite != NULL) { |
zgu@3900 | 191 | if (prev_malloc_callsite == NULL || |
zgu@3900 | 192 | cur_malloc_callsite->addr() < prev_malloc_callsite->addr()) { |
zgu@3900 | 193 | _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), |
zgu@3900 | 194 | amount_in_current_scale(cur_malloc_callsite->amount()), |
zgu@3900 | 195 | cur_malloc_callsite->count(), |
zgu@3900 | 196 | diff_in_current_scale(cur_malloc_callsite->amount(), 0), |
zgu@3900 | 197 | diff(cur_malloc_callsite->count(), 0)); |
zgu@3900 | 198 | cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); |
zgu@3900 | 199 | } else if (prev_malloc_callsite == NULL || |
zgu@3900 | 200 | cur_malloc_callsite->addr() > prev_malloc_callsite->addr()) { |
zgu@3900 | 201 | _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), |
zgu@3900 | 202 | amount_in_current_scale(prev_malloc_callsite->amount()), |
zgu@3900 | 203 | prev_malloc_callsite->count(), |
zgu@3900 | 204 | diff_in_current_scale(0, prev_malloc_callsite->amount()), |
zgu@3900 | 205 | diff(0, prev_malloc_callsite->count())); |
zgu@3900 | 206 | prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); |
zgu@3900 | 207 | } else { // the same callsite |
zgu@3900 | 208 | _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), |
zgu@3900 | 209 | amount_in_current_scale(cur_malloc_callsite->amount()), |
zgu@3900 | 210 | cur_malloc_callsite->count(), |
zgu@3900 | 211 | diff_in_current_scale(cur_malloc_callsite->amount(), prev_malloc_callsite->amount()), |
zgu@3900 | 212 | diff(cur_malloc_callsite->count(), prev_malloc_callsite->count())); |
zgu@3900 | 213 | cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); |
zgu@3900 | 214 | prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); |
zgu@3900 | 215 | } |
zgu@3900 | 216 | } |
zgu@3900 | 217 | |
zgu@3900 | 218 | // walk virtual memory callsite |
zgu@3900 | 219 | MemPointerArrayIteratorImpl cur_vm_itr(pBL_cur->_vm_cs); |
zgu@3900 | 220 | MemPointerArrayIteratorImpl prev_vm_itr(pBL_prev->_vm_cs); |
zgu@3900 | 221 | VMCallsitePointer* cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.current(); |
zgu@3900 | 222 | VMCallsitePointer* prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.current(); |
zgu@3900 | 223 | while (cur_vm_callsite != NULL || prev_vm_callsite != NULL) { |
zgu@3900 | 224 | if (prev_vm_callsite == NULL || cur_vm_callsite->addr() < prev_vm_callsite->addr()) { |
zgu@3900 | 225 | _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(), |
zgu@3900 | 226 | amount_in_current_scale(cur_vm_callsite->reserved_amount()), |
zgu@3900 | 227 | amount_in_current_scale(cur_vm_callsite->committed_amount()), |
zgu@3900 | 228 | diff_in_current_scale(cur_vm_callsite->reserved_amount(), 0), |
zgu@3900 | 229 | diff_in_current_scale(cur_vm_callsite->committed_amount(), 0)); |
zgu@3900 | 230 | cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next(); |
zgu@3900 | 231 | } else if (cur_vm_callsite == NULL || cur_vm_callsite->addr() > prev_vm_callsite->addr()) { |
zgu@3900 | 232 | _outputer.diff_virtual_memory_callsite(prev_vm_callsite->addr(), |
zgu@3900 | 233 | amount_in_current_scale(prev_vm_callsite->reserved_amount()), |
zgu@3900 | 234 | amount_in_current_scale(prev_vm_callsite->committed_amount()), |
zgu@3900 | 235 | diff_in_current_scale(0, prev_vm_callsite->reserved_amount()), |
zgu@3900 | 236 | diff_in_current_scale(0, prev_vm_callsite->committed_amount())); |
zgu@3900 | 237 | prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next(); |
zgu@3900 | 238 | } else { // the same callsite |
zgu@3900 | 239 | _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(), |
zgu@3900 | 240 | amount_in_current_scale(cur_vm_callsite->reserved_amount()), |
zgu@3900 | 241 | amount_in_current_scale(cur_vm_callsite->committed_amount()), |
zgu@3900 | 242 | diff_in_current_scale(cur_vm_callsite->reserved_amount(), prev_vm_callsite->reserved_amount()), |
zgu@3900 | 243 | diff_in_current_scale(cur_vm_callsite->committed_amount(), prev_vm_callsite->committed_amount())); |
zgu@3900 | 244 | cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next(); |
zgu@3900 | 245 | prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next(); |
zgu@3900 | 246 | } |
zgu@3900 | 247 | } |
zgu@3900 | 248 | |
zgu@3900 | 249 | _outputer.done_callsite(); |
zgu@3900 | 250 | } |
zgu@3900 | 251 | |
zgu@3900 | 252 | size_t BaselineReporter::amount_in_current_scale(size_t amt) const { |
zgu@3900 | 253 | return (size_t)(((float)amt/(float)_scale) + 0.5); |
zgu@3900 | 254 | } |
zgu@3900 | 255 | |
zgu@3900 | 256 | int BaselineReporter::diff_in_current_scale(size_t value1, size_t value2) const { |
zgu@3900 | 257 | return (int)(((float)value1 - (float)value2)/((float)_scale) + 0.5); |
zgu@3900 | 258 | } |
zgu@3900 | 259 | |
zgu@3900 | 260 | int BaselineReporter::diff(size_t value1, size_t value2) const { |
zgu@3900 | 261 | return ((int)value1 - (int)value2); |
zgu@3900 | 262 | } |
zgu@3900 | 263 | |
zgu@3900 | 264 | void BaselineTTYOutputer::start(size_t scale, bool report_diff) { |
zgu@3900 | 265 | _scale = scale; |
zgu@3900 | 266 | _output->print_cr(" "); |
zgu@3900 | 267 | _output->print_cr("Native Memory Tracking:"); |
zgu@3900 | 268 | _output->print_cr(" "); |
zgu@3900 | 269 | } |
zgu@3900 | 270 | |
zgu@3900 | 271 | void BaselineTTYOutputer::done() { |
zgu@3900 | 272 | |
zgu@3900 | 273 | } |
zgu@3900 | 274 | |
zgu@3900 | 275 | void BaselineTTYOutputer::total_usage(size_t total_reserved, size_t total_committed) { |
zgu@3900 | 276 | const char* unit = memory_unit(_scale); |
zgu@3900 | 277 | _output->print_cr("Total: reserved=%d%s, committed=%d%s", |
zgu@3900 | 278 | total_reserved, unit, total_committed, unit); |
zgu@3900 | 279 | } |
zgu@3900 | 280 | |
zgu@3900 | 281 | void BaselineTTYOutputer::start_category_summary() { |
zgu@3900 | 282 | _output->print_cr(" "); |
zgu@3900 | 283 | } |
zgu@3900 | 284 | |
zgu@3900 | 285 | /** |
zgu@3900 | 286 | * report a summary of memory type |
zgu@3900 | 287 | */ |
zgu@3900 | 288 | void BaselineTTYOutputer::category_summary(MEMFLAGS type, |
zgu@3900 | 289 | size_t reserved_amt, size_t committed_amt, size_t malloc_amt, |
zgu@3900 | 290 | size_t malloc_count, size_t arena_amt, size_t arena_count) { |
zgu@3900 | 291 | |
zgu@3900 | 292 | // we report mtThreadStack under mtThread category |
zgu@3900 | 293 | if (type == mtThreadStack) { |
zgu@3900 | 294 | assert(malloc_amt == 0 && malloc_count == 0 && arena_amt == 0, |
zgu@3900 | 295 | "Just check"); |
zgu@3900 | 296 | _thread_stack_reserved = reserved_amt; |
zgu@3900 | 297 | _thread_stack_committed = committed_amt; |
zgu@3900 | 298 | } else { |
zgu@3900 | 299 | const char* unit = memory_unit(_scale); |
zgu@3900 | 300 | size_t total_reserved = (reserved_amt + malloc_amt + arena_amt); |
zgu@3900 | 301 | size_t total_committed = (committed_amt + malloc_amt + arena_amt); |
zgu@3900 | 302 | if (type == mtThread) { |
zgu@3900 | 303 | total_reserved += _thread_stack_reserved; |
zgu@3900 | 304 | total_committed += _thread_stack_committed; |
zgu@3900 | 305 | } |
zgu@3900 | 306 | |
zgu@3900 | 307 | if (total_reserved > 0) { |
zgu@3900 | 308 | _output->print_cr("-%26s (reserved=%d%s, committed=%d%s)", |
zgu@3900 | 309 | MemBaseline::type2name(type), total_reserved, unit, |
zgu@3900 | 310 | total_committed, unit); |
zgu@3900 | 311 | |
zgu@3900 | 312 | if (type == mtClass) { |
zgu@3900 | 313 | _output->print_cr("%27s (classes #%d)", " ", _num_of_classes); |
zgu@3900 | 314 | } else if (type == mtThread) { |
zgu@3900 | 315 | _output->print_cr("%27s (thread #%d)", " ", _num_of_threads); |
zgu@3900 | 316 | _output->print_cr("%27s (stack: reserved=%d%s, committed=%d%s)", " ", |
zgu@3900 | 317 | _thread_stack_reserved, unit, _thread_stack_committed, unit); |
zgu@3900 | 318 | } |
zgu@3900 | 319 | |
zgu@3900 | 320 | if (malloc_amt > 0) { |
zgu@3900 | 321 | if (type != mtChunk) { |
zgu@3900 | 322 | _output->print_cr("%27s (malloc=%d%s, #%d)", " ", malloc_amt, unit, |
zgu@3900 | 323 | malloc_count); |
zgu@3900 | 324 | } else { |
zgu@3900 | 325 | _output->print_cr("%27s (malloc=%d%s)", " ", malloc_amt, unit); |
zgu@3900 | 326 | } |
zgu@3900 | 327 | } |
zgu@3900 | 328 | |
zgu@3900 | 329 | if (reserved_amt > 0) { |
zgu@3900 | 330 | _output->print_cr("%27s (mmap: reserved=%d%s, committed=%d%s)", |
zgu@3900 | 331 | " ", reserved_amt, unit, committed_amt, unit); |
zgu@3900 | 332 | } |
zgu@3900 | 333 | |
zgu@3900 | 334 | if (arena_amt > 0) { |
zgu@3900 | 335 | _output->print_cr("%27s (arena=%d%s, #%d)", " ", arena_amt, unit, arena_count); |
zgu@3900 | 336 | } |
zgu@3900 | 337 | |
zgu@3900 | 338 | _output->print_cr(" "); |
zgu@3900 | 339 | } |
zgu@3900 | 340 | } |
zgu@3900 | 341 | } |
zgu@3900 | 342 | |
zgu@3900 | 343 | void BaselineTTYOutputer::done_category_summary() { |
zgu@3900 | 344 | _output->print_cr(" "); |
zgu@3900 | 345 | } |
zgu@3900 | 346 | |
zgu@4193 | 347 | |
zgu@4193 | 348 | void BaselineTTYOutputer::start_virtual_memory_map() { |
zgu@4193 | 349 | _output->print_cr("Virtual memory map:"); |
zgu@4193 | 350 | } |
zgu@4193 | 351 | |
zgu@4193 | 352 | void BaselineTTYOutputer::reserved_memory_region(MEMFLAGS type, address base, address end, |
zgu@4193 | 353 | size_t size, address pc) { |
zgu@4193 | 354 | const char* unit = memory_unit(_scale); |
zgu@4193 | 355 | char buf[128]; |
zgu@4193 | 356 | int offset; |
zgu@4193 | 357 | _output->print_cr(" "); |
zgu@4193 | 358 | _output->print_cr("[" PTR_FORMAT " - " PTR_FORMAT "] reserved %d%s for %s", base, end, size, unit, |
zgu@4193 | 359 | MemBaseline::type2name(type)); |
zgu@4193 | 360 | if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
zgu@4193 | 361 | _output->print_cr("\t\tfrom [%s+0x%x]", buf, offset); |
zgu@4193 | 362 | } |
zgu@4193 | 363 | } |
zgu@4193 | 364 | |
zgu@4193 | 365 | void BaselineTTYOutputer::committed_memory_region(address base, address end, size_t size, address pc) { |
zgu@4193 | 366 | const char* unit = memory_unit(_scale); |
zgu@4193 | 367 | char buf[128]; |
zgu@4193 | 368 | int offset; |
zgu@4193 | 369 | _output->print("\t[" PTR_FORMAT " - " PTR_FORMAT "] committed %d%s", base, end, size, unit); |
zgu@4193 | 370 | if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
zgu@4193 | 371 | _output->print_cr(" from [%s+0x%x]", buf, offset); |
zgu@4193 | 372 | } |
zgu@4193 | 373 | } |
zgu@4193 | 374 | |
zgu@4193 | 375 | void BaselineTTYOutputer::done_virtual_memory_map() { |
zgu@4193 | 376 | _output->print_cr(" "); |
zgu@4193 | 377 | } |
zgu@4193 | 378 | |
zgu@4193 | 379 | |
zgu@4193 | 380 | |
zgu@3900 | 381 | void BaselineTTYOutputer::start_callsite() { |
zgu@3900 | 382 | _output->print_cr("Details:"); |
zgu@3900 | 383 | _output->print_cr(" "); |
zgu@3900 | 384 | } |
zgu@3900 | 385 | |
zgu@3900 | 386 | void BaselineTTYOutputer::done_callsite() { |
zgu@3900 | 387 | _output->print_cr(" "); |
zgu@3900 | 388 | } |
zgu@3900 | 389 | |
zgu@3900 | 390 | void BaselineTTYOutputer::malloc_callsite(address pc, size_t malloc_amt, |
zgu@3900 | 391 | size_t malloc_count) { |
zgu@3900 | 392 | if (malloc_amt > 0) { |
zgu@3900 | 393 | const char* unit = memory_unit(_scale); |
zgu@4193 | 394 | char buf[128]; |
zgu@3900 | 395 | int offset; |
zgu@3900 | 396 | if (pc == 0) { |
zgu@3900 | 397 | _output->print("[BOOTSTRAP]%18s", " "); |
zgu@3900 | 398 | } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
zgu@3900 | 399 | _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); |
zgu@3900 | 400 | _output->print("%28s", " "); |
zgu@3900 | 401 | } else { |
zgu@3900 | 402 | _output->print("[" PTR_FORMAT "]%18s", pc, " "); |
zgu@3900 | 403 | } |
zgu@3900 | 404 | |
zgu@3900 | 405 | _output->print_cr("(malloc=%d%s #%d)", malloc_amt, unit, malloc_count); |
zgu@3900 | 406 | _output->print_cr(" "); |
zgu@3900 | 407 | } |
zgu@3900 | 408 | } |
zgu@3900 | 409 | |
zgu@3900 | 410 | void BaselineTTYOutputer::virtual_memory_callsite(address pc, size_t reserved_amt, |
zgu@3900 | 411 | size_t committed_amt) { |
zgu@3900 | 412 | if (reserved_amt > 0) { |
zgu@3900 | 413 | const char* unit = memory_unit(_scale); |
zgu@4193 | 414 | char buf[128]; |
zgu@3900 | 415 | int offset; |
zgu@3900 | 416 | if (pc == 0) { |
zgu@3900 | 417 | _output->print("[BOOTSTRAP]%18s", " "); |
zgu@3900 | 418 | } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
zgu@3900 | 419 | _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); |
zgu@3900 | 420 | _output->print("%28s", " "); |
zgu@3900 | 421 | } else { |
zgu@3900 | 422 | _output->print("[" PTR_FORMAT "]%18s", " "); |
zgu@3900 | 423 | } |
zgu@3900 | 424 | |
zgu@3900 | 425 | _output->print_cr("(mmap: reserved=%d%s, committed=%d%s)", |
zgu@3900 | 426 | reserved_amt, unit, committed_amt, unit); |
zgu@3900 | 427 | _output->print_cr(" "); |
zgu@3900 | 428 | } |
zgu@3900 | 429 | } |
zgu@3900 | 430 | |
zgu@3900 | 431 | void BaselineTTYOutputer::diff_total_usage(size_t total_reserved, |
zgu@3900 | 432 | size_t total_committed, int reserved_diff, int committed_diff) { |
zgu@3900 | 433 | const char* unit = memory_unit(_scale); |
zgu@3900 | 434 | _output->print_cr("Total: reserved=%d%s %+d%s, committed=%d%s %+d%s", |
zgu@3900 | 435 | total_reserved, unit, reserved_diff, unit, total_committed, unit, |
zgu@3900 | 436 | committed_diff, unit); |
zgu@3900 | 437 | } |
zgu@3900 | 438 | |
zgu@3900 | 439 | void BaselineTTYOutputer::diff_category_summary(MEMFLAGS type, |
zgu@3900 | 440 | size_t cur_reserved_amt, size_t cur_committed_amt, |
zgu@3900 | 441 | size_t cur_malloc_amt, size_t cur_malloc_count, |
zgu@3900 | 442 | size_t cur_arena_amt, size_t cur_arena_count, |
zgu@3900 | 443 | int reserved_diff, int committed_diff, int malloc_diff, |
zgu@3900 | 444 | int malloc_count_diff, int arena_diff, int arena_count_diff) { |
zgu@3900 | 445 | |
zgu@3900 | 446 | if (type == mtThreadStack) { |
zgu@3900 | 447 | assert(cur_malloc_amt == 0 && cur_malloc_count == 0 && |
zgu@3900 | 448 | cur_arena_amt == 0, "Just check"); |
zgu@3900 | 449 | _thread_stack_reserved = cur_reserved_amt; |
zgu@3900 | 450 | _thread_stack_committed = cur_committed_amt; |
zgu@3900 | 451 | _thread_stack_reserved_diff = reserved_diff; |
zgu@3900 | 452 | _thread_stack_committed_diff = committed_diff; |
zgu@3900 | 453 | } else { |
zgu@3900 | 454 | const char* unit = memory_unit(_scale); |
zgu@3900 | 455 | size_t total_reserved = (cur_reserved_amt + cur_malloc_amt + cur_arena_amt); |
zgu@3900 | 456 | // nothing to report in this category |
zgu@3900 | 457 | if (total_reserved == 0) { |
zgu@3900 | 458 | return; |
zgu@3900 | 459 | } |
zgu@3900 | 460 | int diff_reserved = (reserved_diff + malloc_diff + arena_diff); |
zgu@3900 | 461 | |
zgu@3900 | 462 | // category summary |
zgu@3900 | 463 | _output->print("-%26s (reserved=%d%s", MemBaseline::type2name(type), |
zgu@3900 | 464 | total_reserved, unit); |
zgu@3900 | 465 | |
zgu@3900 | 466 | if (diff_reserved != 0) { |
zgu@3900 | 467 | _output->print(" %+d%s", diff_reserved, unit); |
zgu@3900 | 468 | } |
zgu@3900 | 469 | |
zgu@3900 | 470 | size_t total_committed = cur_committed_amt + cur_malloc_amt + cur_arena_amt; |
zgu@3900 | 471 | _output->print(", committed=%d%s", total_committed, unit); |
zgu@3900 | 472 | |
zgu@3900 | 473 | int total_committed_diff = committed_diff + malloc_diff + arena_diff; |
zgu@3900 | 474 | if (total_committed_diff != 0) { |
zgu@3900 | 475 | _output->print(" %+d%s", total_committed_diff, unit); |
zgu@3900 | 476 | } |
zgu@3900 | 477 | |
zgu@3900 | 478 | _output->print_cr(")"); |
zgu@3900 | 479 | |
zgu@3900 | 480 | // special cases |
zgu@3900 | 481 | if (type == mtClass) { |
zgu@3900 | 482 | _output->print("%27s (classes #%d", " ", _num_of_classes); |
zgu@3900 | 483 | if (_num_of_classes_diff != 0) { |
zgu@3900 | 484 | _output->print(" %+d", _num_of_classes_diff); |
zgu@3900 | 485 | } |
zgu@3900 | 486 | _output->print_cr(")"); |
zgu@3900 | 487 | } else if (type == mtThread) { |
zgu@3900 | 488 | // thread count |
zgu@3900 | 489 | _output->print("%27s (thread #%d", " ", _num_of_threads); |
zgu@3900 | 490 | if (_num_of_threads_diff != 0) { |
zgu@3900 | 491 | _output->print_cr(" %+d)", _num_of_threads_diff); |
zgu@3900 | 492 | } else { |
zgu@3900 | 493 | _output->print_cr(")"); |
zgu@3900 | 494 | } |
zgu@3900 | 495 | _output->print("%27s (stack: reserved=%d%s", " ", _thread_stack_reserved, unit); |
zgu@3900 | 496 | if (_thread_stack_reserved_diff != 0) { |
zgu@3900 | 497 | _output->print(" %+d%s", _thread_stack_reserved_diff, unit); |
zgu@3900 | 498 | } |
zgu@3900 | 499 | |
zgu@3900 | 500 | _output->print(", committed=%d%s", _thread_stack_committed, unit); |
zgu@3900 | 501 | if (_thread_stack_committed_diff != 0) { |
zgu@3900 | 502 | _output->print(" %+d%s",_thread_stack_committed_diff, unit); |
zgu@3900 | 503 | } |
zgu@3900 | 504 | |
zgu@3900 | 505 | _output->print_cr(")"); |
zgu@3900 | 506 | } |
zgu@3900 | 507 | |
zgu@3900 | 508 | // malloc'd memory |
zgu@3900 | 509 | if (cur_malloc_amt > 0) { |
zgu@3900 | 510 | _output->print("%27s (malloc=%d%s", " ", cur_malloc_amt, unit); |
zgu@3900 | 511 | if (malloc_diff != 0) { |
zgu@3900 | 512 | _output->print(" %+d%s", malloc_diff, unit); |
zgu@3900 | 513 | } |
zgu@3900 | 514 | if (type != mtChunk) { |
zgu@3900 | 515 | _output->print(", #%d", cur_malloc_count); |
zgu@3900 | 516 | if (malloc_count_diff) { |
zgu@3900 | 517 | _output->print(" %+d", malloc_count_diff); |
zgu@3900 | 518 | } |
zgu@3900 | 519 | } |
zgu@3900 | 520 | _output->print_cr(")"); |
zgu@3900 | 521 | } |
zgu@3900 | 522 | |
zgu@3900 | 523 | // mmap'd memory |
zgu@3900 | 524 | if (cur_reserved_amt > 0) { |
zgu@3900 | 525 | _output->print("%27s (mmap: reserved=%d%s", " ", cur_reserved_amt, unit); |
zgu@3900 | 526 | if (reserved_diff != 0) { |
zgu@3900 | 527 | _output->print(" %+d%s", reserved_diff, unit); |
zgu@3900 | 528 | } |
zgu@3900 | 529 | |
zgu@3900 | 530 | _output->print(", committed=%d%s", cur_committed_amt, unit); |
zgu@3900 | 531 | if (committed_diff != 0) { |
zgu@3900 | 532 | _output->print(" %+d%s", committed_diff, unit); |
zgu@3900 | 533 | } |
zgu@3900 | 534 | _output->print_cr(")"); |
zgu@3900 | 535 | } |
zgu@3900 | 536 | |
zgu@3900 | 537 | // arena memory |
zgu@3900 | 538 | if (cur_arena_amt > 0) { |
zgu@3900 | 539 | _output->print("%27s (arena=%d%s", " ", cur_arena_amt, unit); |
zgu@3900 | 540 | if (arena_diff != 0) { |
zgu@3900 | 541 | _output->print(" %+d%s", arena_diff, unit); |
zgu@3900 | 542 | } |
zgu@3900 | 543 | _output->print(", #%d", cur_arena_count); |
zgu@3900 | 544 | if (arena_count_diff != 0) { |
zgu@3900 | 545 | _output->print(" %+d", arena_count_diff); |
zgu@3900 | 546 | } |
zgu@3900 | 547 | _output->print_cr(")"); |
zgu@3900 | 548 | } |
zgu@3900 | 549 | |
zgu@3900 | 550 | _output->print_cr(" "); |
zgu@3900 | 551 | } |
zgu@3900 | 552 | } |
zgu@3900 | 553 | |
zgu@3900 | 554 | void BaselineTTYOutputer::diff_malloc_callsite(address pc, |
zgu@3900 | 555 | size_t cur_malloc_amt, size_t cur_malloc_count, |
zgu@3900 | 556 | int malloc_diff, int malloc_count_diff) { |
zgu@3900 | 557 | if (malloc_diff != 0) { |
zgu@3900 | 558 | const char* unit = memory_unit(_scale); |
zgu@4193 | 559 | char buf[128]; |
zgu@3900 | 560 | int offset; |
zgu@3900 | 561 | if (pc == 0) { |
zgu@3900 | 562 | _output->print_cr("[BOOTSTRAP]%18s", " "); |
zgu@3900 | 563 | } else { |
zgu@3900 | 564 | if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
zgu@3900 | 565 | _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); |
zgu@3900 | 566 | _output->print("%28s", " "); |
zgu@3900 | 567 | } else { |
zgu@3900 | 568 | _output->print("[" PTR_FORMAT "]%18s", pc, " "); |
zgu@3900 | 569 | } |
zgu@3900 | 570 | } |
zgu@3900 | 571 | |
zgu@3900 | 572 | _output->print("(malloc=%d%s", cur_malloc_amt, unit); |
zgu@3900 | 573 | if (malloc_diff != 0) { |
zgu@3900 | 574 | _output->print(" %+d%s", malloc_diff, unit); |
zgu@3900 | 575 | } |
zgu@3900 | 576 | _output->print(", #%d", cur_malloc_count); |
zgu@3900 | 577 | if (malloc_count_diff != 0) { |
zgu@3900 | 578 | _output->print(" %+d", malloc_count_diff); |
zgu@3900 | 579 | } |
zgu@3900 | 580 | _output->print_cr(")"); |
zgu@3900 | 581 | _output->print_cr(" "); |
zgu@3900 | 582 | } |
zgu@3900 | 583 | } |
zgu@3900 | 584 | |
zgu@3900 | 585 | void BaselineTTYOutputer::diff_virtual_memory_callsite(address pc, |
zgu@3900 | 586 | size_t cur_reserved_amt, size_t cur_committed_amt, |
zgu@3900 | 587 | int reserved_diff, int committed_diff) { |
zgu@3900 | 588 | if (reserved_diff != 0 || committed_diff != 0) { |
zgu@3900 | 589 | const char* unit = memory_unit(_scale); |
zgu@3900 | 590 | char buf[64]; |
zgu@3900 | 591 | int offset; |
zgu@3900 | 592 | if (pc == 0) { |
zgu@3900 | 593 | _output->print_cr("[BOOSTRAP]%18s", " "); |
zgu@3900 | 594 | } else { |
zgu@3900 | 595 | if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
zgu@3900 | 596 | _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); |
zgu@3900 | 597 | _output->print("%28s", " "); |
zgu@3900 | 598 | } else { |
zgu@3900 | 599 | _output->print("[" PTR_FORMAT "]%18s", " "); |
zgu@3900 | 600 | } |
zgu@3900 | 601 | } |
zgu@3900 | 602 | |
zgu@3900 | 603 | _output->print("(mmap: reserved=%d%s", cur_reserved_amt, unit); |
zgu@3900 | 604 | if (reserved_diff != 0) { |
zgu@3900 | 605 | _output->print(" %+d%s", reserved_diff, unit); |
zgu@3900 | 606 | } |
zgu@3900 | 607 | _output->print(", committed=%d%s", cur_committed_amt, unit); |
zgu@3900 | 608 | if (committed_diff != 0) { |
zgu@3900 | 609 | _output->print(" %+d%s", committed_diff, unit); |
zgu@3900 | 610 | } |
zgu@3900 | 611 | _output->print_cr(")"); |
zgu@3900 | 612 | _output->print_cr(" "); |
zgu@3900 | 613 | } |
zgu@3900 | 614 | } |