< prev index next >

src/hotspot/share/memory/metaspace/metaspaceCommon.hpp

Print this page
rev 57601 : [mq]: metaspace-improvement


  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/align.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 
  32 class outputStream;
  33 
  34 namespace metaspace {
  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)                  \


  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   // Number of times a chunk was added to the freelist
  90   uintx num_chunks_added_to_freelist;
  91   // Number of times a chunk was removed from the freelist
  92   uintx num_chunks_removed_from_freelist;
  93   // Number of chunk merges
  94   uintx num_chunk_merges;
  95   // Number of chunk splits
  96   uintx num_chunk_splits;
  97 };
  98 extern internal_statistics_t g_internal_statistics;
  99 #endif
 100 
 101 // ChunkIndex defines the type of chunk.
 102 // Chunk types differ by size: specialized < small < medium, chunks
 103 // larger than medium are humongous chunks of varying size.
 104 enum ChunkIndex {
 105   ZeroIndex = 0,
 106   SpecializedIndex = ZeroIndex,
 107   SmallIndex = SpecializedIndex + 1,
 108   MediumIndex = SmallIndex + 1,
 109   HumongousIndex = MediumIndex + 1,
 110   NumberOfFreeLists = 3,
 111   NumberOfInUseLists = 4
 112 };
 113 
 114 // Utility functions.
 115 size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunk_type, bool is_class);
 116 ChunkIndex get_chunk_type_by_size(size_t size, bool is_class);
 117 
 118 ChunkIndex next_chunk_index(ChunkIndex i);
 119 ChunkIndex prev_chunk_index(ChunkIndex i);
 120 // Returns a descriptive name for a chunk type.
 121 const char* chunk_size_name(ChunkIndex index);
 122 
 123 // Verify chunk sizes.
 124 inline bool is_valid_chunksize(bool is_class, size_t size) {
 125   const size_t reasonable_maximum_humongous_chunk_size = 1 * G;
 126   return is_aligned(size, sizeof(MetaWord)) &&
 127          size < reasonable_maximum_humongous_chunk_size &&
 128          is_class ?
 129              (size == ClassSpecializedChunk || size == ClassSmallChunk || size >= ClassMediumChunk) :
 130              (size == SpecializedChunk || size == SmallChunk || size >= MediumChunk);
 131 }
 132 
 133 // Verify chunk type.
 134 inline bool is_valid_chunktype(ChunkIndex index) {
 135   return index == SpecializedIndex || index == SmallIndex ||
 136          index == MediumIndex || index == HumongousIndex;
 137 }
 138 
 139 inline bool is_valid_nonhumongous_chunktype(ChunkIndex index) {
 140   return is_valid_chunktype(index) && index != HumongousIndex;
 141 }
 142 
 143 // Pretty printing helpers
 144 const char* classes_plural(uintx num);
 145 const char* loaders_plural(uintx num);
 146 void print_number_of_classes(outputStream* out, uintx classes, uintx classes_shared);
 147 
 148 } // namespace metaspace
 149 
 150 #endif // SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP


  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/align.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 
  32 class outputStream;
  33 
  34 namespace metaspace {
  35 








  36 
  37 // Print a size, in words, scaled.
  38 void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1);
  39 
  40 // Convenience helper: prints a size value and a percentage.
  41 void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale = 0, int width = -1);
  42 
  43 // Print a human readable size.
  44 // byte_size: size, in bytes, to be printed.
  45 // scale: one of 1 (byte-wise printing), sizeof(word) (word-size printing), K, M, G (scaled by KB, MB, GB respectively,
  46 //         or 0, which means the best scale is choosen dynamically.
  47 // width: printing width.
  48 void print_human_readable_size(outputStream* st, size_t byte_size, size_t scale = 0, int width = -1);
  49 
  50 // Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values
  51 // larger than 99% but not 100% are displayed as ">100%".
  52 void print_percentage(outputStream* st, size_t total, size_t part);
  53 
  54 
  55 #define assert_is_aligned(value, alignment)                  \


  72   uintx num_vsnodes_purged;
  73   // Number of times we expanded the committed section of the space.
  74   uintx num_committed_space_expanded;
  75   // Number of deallocations
  76   uintx num_deallocs;
  77   // Number of deallocations triggered from outside ("real" deallocations).
  78   uintx num_external_deallocs;
  79   // Number of times an allocation was satisfied from deallocated blocks.
  80   uintx num_allocs_from_deallocated_blocks;
  81   // Number of times a chunk was added to the freelist
  82   uintx num_chunks_added_to_freelist;
  83   // Number of times a chunk was removed from the freelist
  84   uintx num_chunks_removed_from_freelist;
  85   // Number of chunk merges
  86   uintx num_chunk_merges;
  87   // Number of chunk splits
  88   uintx num_chunk_splits;
  89 };
  90 extern internal_statistics_t g_internal_statistics;
  91 #endif










































  92 
  93 // Pretty printing helpers
  94 const char* classes_plural(uintx num);
  95 const char* loaders_plural(uintx num);
  96 void print_number_of_classes(outputStream* out, uintx classes, uintx classes_shared);
  97 
  98 } // namespace metaspace
  99 
 100 #endif // SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP
< prev index next >