8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 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 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_
26 #define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_
27
28 #include "utilities/globalDefinitions.hpp"
29
30
31 class outputStream;
32
33 namespace metaspace {
34 namespace internals {
35
36 // Print a size, in words, scaled.
37 void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1);
38
39 // Convenience helper: prints a size value and a percentage.
40 void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale = 0, int width = -1);
41
42 // Print a human readable size.
43 // byte_size: size, in bytes, to be printed.
44 // scale: one of 1 (byte-wise printing), sizeof(word) (word-size printing), K, M, G (scaled by KB, MB, GB respectively,
45 // or 0, which means the best scale is choosen dynamically.
46 // width: printing width.
47 void print_human_readable_size(outputStream* st, size_t byte_size, size_t scale = 0, int width = -1);
48
49 // Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values
50 // larger than 99% but not 100% are displayed as ">100%".
51 void print_percentage(outputStream* st, size_t total, size_t part);
52
53 } // namespace internals
54 } // namespace metaspace
55
56 #endif /* SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_ */
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 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 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_
26 #define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_
27
28 #include "utilities/debug.hpp"
29 #include "utilities/globalDefinitions.hpp"
30
31 class outputStream;
32
33 namespace metaspace {
34 namespace internals {
35
36 enum ChunkSizes { // in words.
37 ClassSpecializedChunk = 128,
38 SpecializedChunk = 128,
39 ClassSmallChunk = 256,
40 SmallChunk = 512,
41 ClassMediumChunk = 4 * K,
42 MediumChunk = 8 * K
43 };
44
45 // Print a size, in words, scaled.
46 void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1);
47
48 // Convenience helper: prints a size value and a percentage.
49 void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale = 0, int width = -1);
50
51 // Print a human readable size.
52 // byte_size: size, in bytes, to be printed.
53 // scale: one of 1 (byte-wise printing), sizeof(word) (word-size printing), K, M, G (scaled by KB, MB, GB respectively,
54 // or 0, which means the best scale is choosen dynamically.
55 // width: printing width.
56 void print_human_readable_size(outputStream* st, size_t byte_size, size_t scale = 0, int width = -1);
57
58 // Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values
59 // larger than 99% but not 100% are displayed as ">100%".
60 void print_percentage(outputStream* st, size_t total, size_t part);
61
62
63 #define assert_is_aligned(value, alignment) \
64 assert(is_aligned((value), (alignment)), \
65 SIZE_FORMAT_HEX " is not aligned to " \
66 SIZE_FORMAT, (size_t)(uintptr_t)value, (alignment))
67
68 // Internal statistics.
69 #ifdef ASSERT
70 struct internal_statistics_t {
71 // Number of allocations.
72 uintx num_allocs;
73 // Number of times a ClassLoaderMetaspace was born...
74 uintx num_metaspace_births;
75 // ... and died.
76 uintx num_metaspace_deaths;
77 // Number of times VirtualSpaceListNodes were created...
78 uintx num_vsnodes_created;
79 // ... and purged.
80 uintx num_vsnodes_purged;
81 // Number of times we expanded the committed section of the space.
82 uintx num_committed_space_expanded;
83 // Number of deallocations
84 uintx num_deallocs;
85 // Number of deallocations triggered from outside ("real" deallocations).
86 uintx num_external_deallocs;
87 // Number of times an allocation was satisfied from deallocated blocks.
88 uintx num_allocs_from_deallocated_blocks;
89 };
90 extern internal_statistics_t g_internal_statistics;
91 #endif
92
93 // ChunkIndex defines the type of chunk.
94 // Chunk types differ by size: specialized < small < medium, chunks
95 // larger than medium are humongous chunks of varying size.
96 enum ChunkIndex {
97 ZeroIndex = 0,
98 SpecializedIndex = ZeroIndex,
99 SmallIndex = SpecializedIndex + 1,
100 MediumIndex = SmallIndex + 1,
101 HumongousIndex = MediumIndex + 1,
102 NumberOfFreeLists = 3,
103 NumberOfInUseLists = 4
104 };
105
106 // Utility functions.
107 size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunk_type, bool is_class);
108 ChunkIndex get_chunk_type_by_size(size_t size, bool is_class);
109
110 ChunkIndex next_chunk_index(ChunkIndex i);
111 ChunkIndex prev_chunk_index(ChunkIndex i);
112 // Returns a descriptive name for a chunk type.
113 const char* chunk_size_name(ChunkIndex index);
114
115 // Verify chunk type.
116 inline bool is_valid_chunktype(ChunkIndex index) {
117 return index == SpecializedIndex || index == SmallIndex ||
118 index == MediumIndex || index == HumongousIndex;
119 }
120
121 inline bool is_valid_nonhumongous_chunktype(ChunkIndex index) {
122 return is_valid_chunktype(index) && index != HumongousIndex;
123 }
124
125
126
127
128 } // namespace internals
129 } // namespace metaspace
130
131 #endif /* SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_ */
|