< prev index next >

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

Print this page
rev 60538 : imported patch jep387-core.patch
   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 "utilities/globalDefinitions.hpp"
  30 #include "memory/metaspace.hpp" // for MetadataType enum
  31 #include "memory/metaspace/metachunk.hpp" // for ChunkIndex enum

  32 
  33 class outputStream;
  34 
  35 namespace metaspace {
  36 
  37 // Contains statistics for a number of free chunks.
  38 class FreeChunksStatistics {
  39   uintx _num;         // Number of chunks
  40   size_t _cap;        // Total capacity, in words
  41 
  42 public:
  43   FreeChunksStatistics();
  44 
  45   void reset();
  46 
  47   uintx num() const { return _num; }
  48   size_t cap() const { return _cap; }
  49 
  50   void add(uintx n, size_t s);
  51   void add(const FreeChunksStatistics& other);
  52   void print_on(outputStream* st, size_t scale) const;
  53 
  54 }; // end: FreeChunksStatistics

  55 

  56 
  57 // Contains statistics for a ChunkManager.
  58 class ChunkManagerStatistics {
  59 
  60   FreeChunksStatistics _chunk_stats[NumberOfInUseLists];

  61 
  62 public:
  63 
  64   // Free chunk statistics, by chunk index.
  65   const FreeChunksStatistics& chunk_stats(ChunkIndex index) const   { return _chunk_stats[index]; }
  66   FreeChunksStatistics& chunk_stats(ChunkIndex index)               { return _chunk_stats[index]; }
  67 
  68   void reset();
  69   size_t total_capacity() const;
  70 
  71   void print_on(outputStream* st, size_t scale) const;
  72 
  73 }; // ChunkManagerStatistics
  74 
  75 // Contains statistics for a number of chunks in use.
  76 // Each chunk has a used and free portion; however, there are current chunks (serving
  77 // potential future metaspace allocations) and non-current chunks. Unused portion of the
  78 // former is counted as free, unused portion of the latter counts as waste.
  79 class UsedChunksStatistics {
  80   uintx _num;     // Number of chunks
  81   size_t _cap;    // Total capacity in words.
  82   size_t _used;   // Total used area, in words
  83   size_t _free;   // Total free area (unused portions of current chunks), in words
  84   size_t _waste;  // Total waste area (unused portions of non-current chunks), in words
  85   size_t _overhead; // Total sum of chunk overheads, in words.
  86 
  87 public:

  88 
  89   UsedChunksStatistics();

  90 
  91   void reset();


  92 
  93   uintx num() const { return _num; }


  94 
  95   // Total capacity, in words
  96   size_t cap() const { return _cap; }
  97 
  98   // Total used area, in words
  99   size_t used() const { return _used; }
 100 
 101   // Total free area (unused portions of current chunks), in words
 102   size_t free() const { return _free; }
 103 
 104   // Total waste area (unused portions of non-current chunks), in words
 105   size_t waste() const { return _waste; }
 106 
 107   // Total area spent in overhead (chunk headers), in words
 108   size_t overhead() const { return _overhead; }


 109 
 110   void add_num(uintx n) { _num += n; }
 111   void add_cap(size_t s) { _cap += s; }
 112   void add_used(size_t s) { _used += s; }
 113   void add_free(size_t s) { _free += s; }
 114   void add_waste(size_t s) { _waste += s; }
 115   void add_overhead(size_t s) { _overhead += s; }

 116 
 117   void add(const UsedChunksStatistics& other);
 118 
 119   void print_on(outputStream* st, size_t scale) const;
 120 
 121 #ifdef ASSERT
 122   void check_sanity() const;
 123 #endif
 124 
 125 }; // UsedChunksStatistics
 126 
 127 // Class containing statistics for one or more space managers.
 128 class SpaceManagerStatistics {
 129 
 130   UsedChunksStatistics _chunk_stats[NumberOfInUseLists];
 131   uintx _free_blocks_num;
 132   size_t _free_blocks_cap_words;

 133 
 134 public:




 135 
 136   SpaceManagerStatistics();
 137 
 138   // Chunk statistics by chunk index
 139   const UsedChunksStatistics& chunk_stats(ChunkIndex index) const   { return _chunk_stats[index]; }
 140   UsedChunksStatistics& chunk_stats(ChunkIndex index)               { return _chunk_stats[index]; }
 141 
 142   uintx free_blocks_num () const                                    { return _free_blocks_num; }
 143   size_t free_blocks_cap_words () const                             { return _free_blocks_cap_words; }
 144 
 145   void reset();
 146 
 147   void add_free_blocks_info(uintx num, size_t cap);
 148 
 149   // Returns total chunk statistics over all chunk types.
 150   UsedChunksStatistics totals() const;
 151 
 152   void add(const SpaceManagerStatistics& other);
 153 
 154   void print_on(outputStream* st, size_t scale,  bool detailed) const;
 155 
 156 }; // SpaceManagerStatistics
 157 
 158 class ClassLoaderMetaspaceStatistics {



 159 
 160   SpaceManagerStatistics _sm_stats[Metaspace::MetadataTypeCount];
 161 
 162 public:
 163 
 164   ClassLoaderMetaspaceStatistics();
 165 
 166   const SpaceManagerStatistics& sm_stats(Metaspace::MetadataType mdType) const { return _sm_stats[mdType]; }
 167   SpaceManagerStatistics& sm_stats(Metaspace::MetadataType mdType)             { return _sm_stats[mdType]; }
 168 
 169   const SpaceManagerStatistics& nonclass_sm_stats() const { return sm_stats(Metaspace::NonClassType); }
 170   SpaceManagerStatistics& nonclass_sm_stats()             { return sm_stats(Metaspace::NonClassType); }
 171   const SpaceManagerStatistics& class_sm_stats() const    { return sm_stats(Metaspace::ClassType); }
 172   SpaceManagerStatistics& class_sm_stats()                { return sm_stats(Metaspace::ClassType); }
 173 
 174   void reset();
 175 
 176   void add(const ClassLoaderMetaspaceStatistics& other);

 177 
 178   // Returns total space manager statistics for both class and non-class metaspace
 179   SpaceManagerStatistics totals() const;
 180 
 181   void print_on(outputStream* st, size_t scale, bool detailed) const;
 182 
 183 }; // ClassLoaderMetaspaceStatistics
 184 
 185 } // namespace metaspace
 186 
 187 #endif // SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP

   1 /*
   2  * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2018, 2020 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 a number of data output structures:
  38 //
  39 // - cm_stats_t
  40 // - clms_stats_t -> arena_stats_t -> in_use_chunk_stats_t
  41 //
  42 // used for the various XXXX::add_to_statistic() methods in MetaspaceArena, ClassLoaderMetaspace
  43 //  and ChunkManager, respectively.
  44 
  45 struct cm_stats_t {
  46 
  47   // How many chunks per level are checked in.
  48   int num_chunks[chunklevel::NUM_CHUNK_LEVELS];




  49 
  50   // Size, in words, of the sum of all committed areas in this chunk manager, per level.
  51   size_t committed_word_size[chunklevel::NUM_CHUNK_LEVELS];
  52 
  53   cm_stats_t() : num_chunks(), committed_word_size() {}
  54 
  55   void add(const cm_stats_t& other);

  56 
  57   // Returns total word size of all chunks in this manager.
  58   size_t total_word_size() const;
  59 
  60   // Returns total committed word size of all chunks in this manager.
  61   size_t total_committed_word_size() const;






  62 
  63   void print_on(outputStream* st, size_t scale) const;
  64 
  65   DEBUG_ONLY(void verify() const;)
  66 
  67 };










  68 
  69 // Contains statistics for one or multiple chunks in use.
  70 struct in_use_chunk_stats_t {
  71 
  72   // Number of chunks
  73   int num;
  74 
  75   // Note:
  76   // capacity = committed + uncommitted
  77   //            committed = used + free + waste
  78 
  79   // Capacity (total sum of all chunk sizes) in words.
  80   // May contain committed and uncommitted space.
  81   size_t word_size;
  82 
  83   // Total committed area, in words.
  84   size_t committed_words;
  85 
  86   // Total used area, in words.
  87   size_t used_words;
  88 
  89   // Total free committed area, in words.
  90   size_t free_words;
  91 
  92   // Total waste committed area, in words.
  93   size_t waste_words;
  94 
  95   in_use_chunk_stats_t()
  96     : num(0), word_size(0), committed_words(0),
  97       used_words(0), free_words(0), waste_words(0)
  98   {}
  99 
 100   void add(const in_use_chunk_stats_t& other) {
 101     num += other.num;
 102     word_size += other.word_size;
 103     committed_words += other.committed_words;
 104     used_words += other.used_words;
 105     free_words += other.free_words;
 106     waste_words += other.waste_words;
 107 
 108   }
 109 
 110   void print_on(outputStream* st, size_t scale) const;
 111 
 112   DEBUG_ONLY(void verify() const;)


 113 
 114 };
 115 
 116 // Class containing statistics for one or more MetaspaceArena objects.
 117 struct  arena_stats_t {
 118 
 119   // chunk statistics by chunk level
 120   in_use_chunk_stats_t stats[chunklevel::NUM_CHUNK_LEVELS];
 121   uintx free_blocks_num;
 122   size_t free_blocks_word_size;
 123 
 124   arena_stats_t()
 125     : stats(),
 126       free_blocks_num(0),
 127       free_blocks_word_size(0)
 128   {}
 129 
 130   void add(const arena_stats_t& other);
 131 
 132   void print_on(outputStream* st, size_t scale = K,  bool detailed = true) const;


 133 
 134   in_use_chunk_stats_t totals() const;

 135 
 136   DEBUG_ONLY(void verify() const;)
 137 
 138 };
 139 
 140 // Statistics for one or multiple ClassLoaderMetaspace objects
 141 struct clms_stats_t {
 142 
 143   arena_stats_t arena_stats_nonclass;
 144   arena_stats_t arena_stats_class;

 145 
 146   clms_stats_t() : arena_stats_nonclass(), arena_stats_class() {}
 147 
 148   void add(const clms_stats_t& other) {
 149     arena_stats_nonclass.add(other.arena_stats_nonclass);
 150     arena_stats_class.add(other.arena_stats_class);
 151   }
 152 
 153   void print_on(outputStream* st, size_t scale, bool detailed) const;














 154 
 155   // Returns total statistics for both class and non-class metaspace
 156   arena_stats_t totals() const;
 157 


 158 
 159   DEBUG_ONLY(void verify() const;)
 160 
 161 };
 162 
 163 } // namespace metaspace
 164 
 165 #endif // SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP
 166 
< prev index next >