Path: blob/master/src/hotspot/share/memory/metaspace/internalStats.hpp
40957 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 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_INTERNALSTATS_HPP26#define SHARE_MEMORY_METASPACE_INTERNALSTATS_HPP2728#include "memory/allocation.hpp"29#include "runtime/atomic.hpp"30#include "utilities/globalDefinitions.hpp"3132class outputStream;3334namespace metaspace {3536// These are some counters useful for debugging and analyzing Metaspace problems.37// They get printed as part of the Metaspace report (e.g. via jcmd VM.metaspace)3839class InternalStats : public AllStatic {4041// Note: all counters which are modified on the classloader local allocation path42// (not under ExpandLock protection) have to be atomic.4344#define ALL_MY_COUNTERS(x, x_atomic) \45\46/* Number of allocations. */ \47DEBUG_ONLY(x_atomic(num_allocs)) \48\49/* Number of external deallocations */ \50/* (excluding retired chunk remains) */ \51DEBUG_ONLY(x_atomic(num_deallocs)) \52\53/* Number of times an allocation was satisfied */ \54/* from deallocated blocks. */ \55DEBUG_ONLY(x_atomic(num_allocs_from_deallocated_blocks)) \56\57/* Number of times an arena retired a chunk */ \58DEBUG_ONLY(x_atomic(num_chunks_retired)) \59\60/* Number of times an allocation failed */ \61/* because we hit a limit. */ \62x_atomic(num_allocs_failed_limit) \63\64/* Number of times an arena was born ... */ \65x_atomic(num_arena_births) \66/* ... and died. */ \67x_atomic(num_arena_deaths) \68\69/* Number of times VirtualSpaceNode were */ \70/* born... */ \71x(num_vsnodes_births) \72/* ... and died. */ \73x(num_vsnodes_deaths) \74\75/* Number of times we committed space. */ \76x(num_space_committed) \77/* Number of times we uncommitted space. */ \78x(num_space_uncommitted) \79\80/* Number of times a chunk was returned to the */ \81/* freelist (external only). */ \82x(num_chunks_returned_to_freelist) \83/* Number of times a chunk was taken from */ \84/* freelist (external only) */ \85x(num_chunks_taken_from_freelist) \86\87/* Number of successful chunk merges */ \88x(num_chunk_merges) \89/* Number of chunk splits */ \90x(num_chunk_splits) \91/* Number of chunk in place enlargements */ \92x(num_chunks_enlarged) \93\94/* Number of times we did a purge */ \95x(num_purges) \96\97/* Number of times we read inconsistent stats. */ \98x(num_inconsistent_stats) \99100// Note: We use uintx since 32bit platforms lack 64bit atomic add; this increases101// the possibility of counter overflows but the probability is very low for any counter102// but num_allocs; note that these counters are for human eyes only.103#define DEFINE_COUNTER(name) static uintx _##name;104#define DEFINE_ATOMIC_COUNTER(name) static volatile uintx _##name;105ALL_MY_COUNTERS(DEFINE_COUNTER, DEFINE_ATOMIC_COUNTER)106#undef DEFINE_COUNTER107#undef DEFINE_ATOMIC_COUNTER108109public:110111// incrementors112#define INCREMENTOR(name) static void inc_##name() { _##name++; }113#define INCREMENTOR_ATOMIC(name) static void inc_##name() { Atomic::inc(&_##name); }114ALL_MY_COUNTERS(INCREMENTOR, INCREMENTOR_ATOMIC)115#undef INCREMENTOR116#undef INCREMENTOR_ATOMIC117118// getters119#define GETTER(name) static uint64_t name() { return _##name; }120ALL_MY_COUNTERS(GETTER, GETTER)121#undef GETTER122123static void print_on(outputStream* st);124125};126127} // namespace metaspace128129#endif // SHARE_MEMORY_METASPACE_INTERNALSTATS_HPP130131132