Path: blob/master/src/hotspot/share/memory/metaspace/metaspaceStatistics.hpp
40957 views
/*1* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2018, 2020 SAP SE. All rights reserved.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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP26#define SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP2728#include "memory/metaspace.hpp" // for MetadataType enum29#include "memory/metaspace/chunklevel.hpp"30#include "utilities/globalDefinitions.hpp"3132class outputStream;3334namespace metaspace {3536// Contains a number of data output structures:37//38// - cm_stats_t39// - clms_stats_t -> arena_stats_t -> in_use_chunk_stats_t40//41// used for the various XXXX::add_to_statistic() methods in MetaspaceArena, ClassLoaderMetaspace42// and ChunkManager, respectively.4344struct ChunkManagerStats {4546// How many chunks per level are checked in.47int _num_chunks[chunklevel::NUM_CHUNK_LEVELS];4849// Size, in words, of the sum of all committed areas in this chunk manager, per level.50size_t _committed_word_size[chunklevel::NUM_CHUNK_LEVELS];5152ChunkManagerStats() : _num_chunks(), _committed_word_size() {}5354void add(const ChunkManagerStats& other);5556// Returns total word size of all chunks in this manager.57size_t total_word_size() const;5859// Returns total committed word size of all chunks in this manager.60size_t total_committed_word_size() const;6162void print_on(outputStream* st, size_t scale) const;6364DEBUG_ONLY(void verify() const;)6566};6768// Contains statistics for one or multiple chunks in use.69struct InUseChunkStats {7071// Number of chunks72int _num;7374// Note:75// capacity = committed + uncommitted76// committed = used + free + waste7778// Capacity (total sum of all chunk sizes) in words.79// May contain committed and uncommitted space.80size_t _word_size;8182// Total committed area, in words.83size_t _committed_words;8485// Total used area, in words.86size_t _used_words;8788// Total free committed area, in words.89size_t _free_words;9091// Total waste committed area, in words.92size_t _waste_words;9394InUseChunkStats() :95_num(0),96_word_size(0),97_committed_words(0),98_used_words(0),99_free_words(0),100_waste_words(0)101{}102103void add(const InUseChunkStats& other) {104_num += other._num;105_word_size += other._word_size;106_committed_words += other._committed_words;107_used_words += other._used_words;108_free_words += other._free_words;109_waste_words += other._waste_words;110111}112113void print_on(outputStream* st, size_t scale) const;114115DEBUG_ONLY(void verify() const;)116117};118119// Class containing statistics for one or more MetaspaceArena objects.120struct ArenaStats {121122// chunk statistics by chunk level123InUseChunkStats _stats[chunklevel::NUM_CHUNK_LEVELS];124uintx _free_blocks_num;125size_t _free_blocks_word_size;126127ArenaStats() :128_stats(),129_free_blocks_num(0),130_free_blocks_word_size(0)131{}132133void add(const ArenaStats& other);134135void print_on(outputStream* st, size_t scale = K, bool detailed = true) const;136137InUseChunkStats totals() const;138139DEBUG_ONLY(void verify() const;)140141};142143// Statistics for one or multiple ClassLoaderMetaspace objects144struct ClmsStats {145146ArenaStats _arena_stats_nonclass;147ArenaStats _arena_stats_class;148149ClmsStats() : _arena_stats_nonclass(), _arena_stats_class() {}150151void add(const ClmsStats& other) {152_arena_stats_nonclass.add(other._arena_stats_nonclass);153_arena_stats_class.add(other._arena_stats_class);154}155156void print_on(outputStream* st, size_t scale, bool detailed) const;157158// Returns total statistics for both class and non-class metaspace159ArenaStats totals() const;160161DEBUG_ONLY(void verify() const;)162163};164165} // namespace metaspace166167#endif // SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP168169170171