< prev index next >

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

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

@@ -24,158 +24,108 @@
  */
 
 #ifndef SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP
 #define SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP
 
-#include "utilities/globalDefinitions.hpp"
 #include "memory/metaspace.hpp" // for MetadataType enum
-#include "memory/metaspace/metachunk.hpp" // for ChunkIndex enum
+#include "memory/metaspace/chunkLevel.hpp"
+#include "utilities/globalDefinitions.hpp"
 
 class outputStream;
 
 namespace metaspace {
 
-// Contains statistics for a number of free chunks.
-class FreeChunksStatistics {
-  uintx _num;         // Number of chunks
-  size_t _cap;        // Total capacity, in words
-
-public:
-  FreeChunksStatistics();
-
-  void reset();
-
-  uintx num() const { return _num; }
-  size_t cap() const { return _cap; }
-
-  void add(uintx n, size_t s);
-  void add(const FreeChunksStatistics& other);
-  void print_on(outputStream* st, size_t scale) const;
-
-}; // end: FreeChunksStatistics
-
-
 // Contains statistics for a ChunkManager.
-class ChunkManagerStatistics {
+struct ChunkManagerStatistics {
 
-  FreeChunksStatistics _chunk_stats[NumberOfInUseLists];
+  // How many chunks per level are checked in.
+  int num_chunks[chklvl::NUM_CHUNK_LEVELS];
 
-public:
+  // Size, in words, of the sum of all committed areas in this chunk manager, per level.
+  size_t committed_word_size[chklvl::NUM_CHUNK_LEVELS];
 
-  // Free chunk statistics, by chunk index.
-  const FreeChunksStatistics& chunk_stats(ChunkIndex index) const   { return _chunk_stats[index]; }
-  FreeChunksStatistics& chunk_stats(ChunkIndex index)               { return _chunk_stats[index]; }
+  ChunkManagerStatistics();
 
-  void reset();
   size_t total_capacity() const;
 
   void print_on(outputStream* st, size_t scale) const;
 
 }; // ChunkManagerStatistics
 
 // Contains statistics for a number of chunks in use.
 // Each chunk has a used and free portion; however, there are current chunks (serving
 // potential future metaspace allocations) and non-current chunks. Unused portion of the
 // former is counted as free, unused portion of the latter counts as waste.
-class UsedChunksStatistics {
-  uintx _num;     // Number of chunks
-  size_t _cap;    // Total capacity in words.
-  size_t _used;   // Total used area, in words
-  size_t _free;   // Total free area (unused portions of current chunks), in words
-  size_t _waste;  // Total waste area (unused portions of non-current chunks), in words
-  size_t _overhead; // Total sum of chunk overheads, in words.
+struct UsedChunksStatistics {
 
-public:
+  // Number of chunks
+  int num;
 
-  UsedChunksStatistics();
 
-  void reset();
+  // Note: all sizes in number of words.
 
-  uintx num() const { return _num; }
+  // Capacity in words. May contain committed and uncommitted space.
+  size_t cap;
 
-  // Total capacity, in words
-  size_t cap() const { return _cap; }
+  // Total used area, in words. May contain committed and uncommitted space.
+  size_t used;
 
-  // Total used area, in words
-  size_t used() const { return _used; }
+  // Total free area (unused portions of current chunks). May contain committed and uncommitted space.
+  size_t free;
 
-  // Total free area (unused portions of current chunks), in words
-  size_t free() const { return _free; }
+  // Total waste area (unused portions of non-current chunks). May contain committed and uncommitted space.
+  size_t waste;
 
-  // Total waste area (unused portions of non-current chunks), in words
-  size_t waste() const { return _waste; }
 
-  // Total area spent in overhead (chunk headers), in words
-  size_t overhead() const { return _overhead; }
+  // Total committed area, in words. May be smaller or larger than used.
+  size_t committed;
 
-  void add_num(uintx n) { _num += n; }
-  void add_cap(size_t s) { _cap += s; }
-  void add_used(size_t s) { _used += s; }
-  void add_free(size_t s) { _free += s; }
-  void add_waste(size_t s) { _waste += s; }
-  void add_overhead(size_t s) { _overhead += s; }
+  UsedChunksStatistics() : num(0), cap(0), used(0), free(0), waste(0), committed(0) {}
 
-  void add(const UsedChunksStatistics& other);
+  void add(const UsedChunksStatistics& other) {
+    num = other.num; cap = other.cap; used = other.used;
+    free = other.free; waste = other.waste;
+  }
 
   void print_on(outputStream* st, size_t scale) const;
 
-#ifdef ASSERT
-  void check_sanity() const;
-#endif
+  DEBUG_ONLY(void check_sanity() const;)
 
 }; // UsedChunksStatistics
 
 // Class containing statistics for one or more space managers.
-class SpaceManagerStatistics {
-
-  UsedChunksStatistics _chunk_stats[NumberOfInUseLists];
-  uintx _free_blocks_num;
-  size_t _free_blocks_cap_words;
-
-public:
-
-  SpaceManagerStatistics();
-
-  // Chunk statistics by chunk index
-  const UsedChunksStatistics& chunk_stats(ChunkIndex index) const   { return _chunk_stats[index]; }
-  UsedChunksStatistics& chunk_stats(ChunkIndex index)               { return _chunk_stats[index]; }
+struct SpaceManagerStatistics {
 
-  uintx free_blocks_num () const                                    { return _free_blocks_num; }
-  size_t free_blocks_cap_words () const                             { return _free_blocks_cap_words; }
+  UsedChunksStatistics chunk_stats[chklvl::NUM_CHUNK_LEVELS];
+  uintx free_blocks_num;
+  size_t free_blocks_word_size;
 
-  void reset();
+  SpaceManagerStatistics() : chunk_stats(), free_blocks_num(0), free_blocks_word_size(0) {}
 
-  void add_free_blocks_info(uintx num, size_t cap);
+  void add_free_blocks_info(uintx num, size_t cap) {
+    free_blocks_num += num; free_blocks_word_size += cap;
+  }
 
-  // Returns total chunk statistics over all chunk types.
+  // Returns total chunk statistics over all chunk levels.
   UsedChunksStatistics totals() const;
 
   void add(const SpaceManagerStatistics& other);
 
   void print_on(outputStream* st, size_t scale,  bool detailed) const;
 
 }; // SpaceManagerStatistics
 
-class ClassLoaderMetaspaceStatistics {
-
-  SpaceManagerStatistics _sm_stats[Metaspace::MetadataTypeCount];
-
-public:
-
-  ClassLoaderMetaspaceStatistics();
-
-  const SpaceManagerStatistics& sm_stats(Metaspace::MetadataType mdType) const { return _sm_stats[mdType]; }
-  SpaceManagerStatistics& sm_stats(Metaspace::MetadataType mdType)             { return _sm_stats[mdType]; }
+struct ClassLoaderMetaspaceStatistics {
 
-  const SpaceManagerStatistics& nonclass_sm_stats() const { return sm_stats(Metaspace::NonClassType); }
-  SpaceManagerStatistics& nonclass_sm_stats()             { return sm_stats(Metaspace::NonClassType); }
-  const SpaceManagerStatistics& class_sm_stats() const    { return sm_stats(Metaspace::ClassType); }
-  SpaceManagerStatistics& class_sm_stats()                { return sm_stats(Metaspace::ClassType); }
+  SpaceManagerStatistics sm_stats[MetadataTypeCount];
 
-  void reset();
+  ClassLoaderMetaspaceStatistics() : sm_stats() {}
 
-  void add(const ClassLoaderMetaspaceStatistics& other);
+  void add(const ClassLoaderMetaspaceStatistics& other) {
+    sm_stats[ClassType].add(other.sm_stats[ClassType]);
+    sm_stats[NonClassType].add(other.sm_stats[NonClassType]);
+  }
 
   // Returns total space manager statistics for both class and non-class metaspace
   SpaceManagerStatistics totals() const;
 
   void print_on(outputStream* st, size_t scale, bool detailed) const;
< prev index next >