Path: blob/master/src/hotspot/share/cds/dumpAllocStats.cpp
41144 views
/*1* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "cds/dumpAllocStats.hpp"26#include "logging/log.hpp"27#include "logging/logMessage.hpp"2829void DumpAllocStats::print_stats(int ro_all, int rw_all) {30// symbols31_counts[RO][SymbolHashentryType] = _symbol_stats.hashentry_count;32_bytes [RO][SymbolHashentryType] = _symbol_stats.hashentry_bytes;3334_counts[RO][SymbolBucketType] = _symbol_stats.bucket_count;35_bytes [RO][SymbolBucketType] = _symbol_stats.bucket_bytes;3637// strings38_counts[RO][StringHashentryType] = _string_stats.hashentry_count;39_bytes [RO][StringHashentryType] = _string_stats.hashentry_bytes;4041_counts[RO][StringBucketType] = _string_stats.bucket_count;42_bytes [RO][StringBucketType] = _string_stats.bucket_bytes;4344// prevent divide-by-zero45if (ro_all < 1) {46ro_all = 1;47}48if (rw_all < 1) {49rw_all = 1;50}5152int all_ro_count = 0;53int all_ro_bytes = 0;54int all_rw_count = 0;55int all_rw_bytes = 0;5657// To make fmt_stats be a syntactic constant (for format warnings), use #define.58#define fmt_stats "%-20s: %8d %10d %5.1f | %8d %10d %5.1f | %8d %10d %5.1f"59const char *sep = "--------------------+---------------------------+---------------------------+--------------------------";60const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %";6162LogMessage(cds) msg;6364msg.debug("Detailed metadata info (excluding heap regions):");65msg.debug("%s", hdr);66msg.debug("%s", sep);67for (int type = 0; type < int(_number_of_types); type ++) {68const char *name = type_name((Type)type);69int ro_count = _counts[RO][type];70int ro_bytes = _bytes [RO][type];71int rw_count = _counts[RW][type];72int rw_bytes = _bytes [RW][type];73int count = ro_count + rw_count;74int bytes = ro_bytes + rw_bytes;7576double ro_perc = percent_of(ro_bytes, ro_all);77double rw_perc = percent_of(rw_bytes, rw_all);78double perc = percent_of(bytes, ro_all + rw_all);7980msg.debug(fmt_stats, name,81ro_count, ro_bytes, ro_perc,82rw_count, rw_bytes, rw_perc,83count, bytes, perc);8485all_ro_count += ro_count;86all_ro_bytes += ro_bytes;87all_rw_count += rw_count;88all_rw_bytes += rw_bytes;89}9091int all_count = all_ro_count + all_rw_count;92int all_bytes = all_ro_bytes + all_rw_bytes;9394double all_ro_perc = percent_of(all_ro_bytes, ro_all);95double all_rw_perc = percent_of(all_rw_bytes, rw_all);96double all_perc = percent_of(all_bytes, ro_all + rw_all);9798msg.debug("%s", sep);99msg.debug(fmt_stats, "Total",100all_ro_count, all_ro_bytes, all_ro_perc,101all_rw_count, all_rw_bytes, all_rw_perc,102all_count, all_bytes, all_perc);103104assert(all_ro_bytes == ro_all, "everything should have been counted");105assert(all_rw_bytes == rw_all, "everything should have been counted");106107#undef fmt_stats108}109110111