rev 57380 : [mq]: metaspace-improvement
1 /* 2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2018 SAP SE. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #ifndef SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP 27 #define SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP 28 29 #include "memory/metaspace.hpp" // for MetadataType enum 30 #include "memory/metaspace/chunkLevel.hpp" 31 #include "utilities/globalDefinitions.hpp" 32 33 class outputStream; 34 35 namespace metaspace { 36 37 // Contains statistics for a number of free chunks. 38 struct FreeChunksStatistics { 39 40 uintx num; // Number of chunks 41 size_t word_size; // Total capacity, in words 42 43 void reset() { num = 0; word_size = 0; } 44 45 void add(uintx n, size_t s) { 46 num += n; word_size += s; 47 } 48 49 void add(const FreeChunksStatistics& other) { 50 num += other.num; word_size += other.word_size; 51 } 52 53 void print_on(outputStream* st, size_t scale) const; 54 55 }; // end: FreeChunksStatistics 56 57 58 // Contains statistics for a ChunkManager. 59 struct ChunkManagerStatistics { 60 61 FreeChunksStatistics chunk_stats[chklvl::NUM_CHUNK_LEVELS]; 62 63 void reset(); 64 size_t total_capacity() const; 65 66 void print_on(outputStream* st, size_t scale) const; 67 68 }; // ChunkManagerStatistics 69 70 // Contains statistics for a number of chunks in use. 71 // Each chunk has a used and free portion; however, there are current chunks (serving 72 // potential future metaspace allocations) and non-current chunks. Unused portion of the 73 // former is counted as free, unused portion of the latter counts as waste. 74 struct UsedChunksStatistics { 75 76 uintx num; // Number of chunks 77 size_t cap; // Total capacity in words. 78 size_t used; // Total used area, in words 79 size_t free; // Total free area (unused portions of current chunks), in words 80 size_t waste; // Total waste area (unused portions of non-current chunks), in words 81 82 void reset() { 83 num = 0; 84 cap = used = free = waste = 0; 85 } 86 87 void add(const UsedChunksStatistics& other) { 88 num = other.num; cap = other.cap; used = other.used; free = other.free; waste = other.waste; 89 } 90 91 void print_on(outputStream* st, size_t scale) const; 92 93 DEBUG_ONLY(void check_sanity() const;) 94 95 }; // UsedChunksStatistics 96 97 // Class containing statistics for one or more space managers. 98 struct SpaceManagerStatistics { 99 100 UsedChunksStatistics chunk_stats[chklvl::NUM_CHUNK_LEVELS]; 101 uintx free_blocks_num; 102 size_t free_blocks_word_size; 103 104 void reset(); 105 106 void add_free_blocks_info(uintx num, size_t cap) { 107 free_blocks_num += num; free_blocks_word_size += cap; 108 } 109 110 // Returns total chunk statistics over all chunk levels. 111 UsedChunksStatistics totals() const; 112 113 void add(const SpaceManagerStatistics& other); 114 115 void print_on(outputStream* st, size_t scale, bool detailed) const; 116 117 }; // SpaceManagerStatistics 118 119 struct ClassLoaderMetaspaceStatistics { 120 121 SpaceManagerStatistics sm_stats[Metaspace::MetadataTypeCount]; 122 123 void reset() { 124 sm_stats[Metaspace::ClassType].reset(); 125 sm_stats[Metaspace::NonClassType].reset(); 126 } 127 128 void add(const ClassLoaderMetaspaceStatistics& other) { 129 sm_stats[Metaspace::ClassType].add(other.sm_stats[Metaspace::ClassType]); 130 sm_stats[Metaspace::NonClassType].add(other.sm_stats[Metaspace::NonClassType]); 131 } 132 133 // Returns total space manager statistics for both class and non-class metaspace 134 SpaceManagerStatistics totals() const; 135 136 void print_on(outputStream* st, size_t scale, bool detailed) const; 137 138 }; // ClassLoaderMetaspaceStatistics 139 140 } // namespace metaspace 141 142 #endif // SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP --- EOF ---