< prev index next >

src/hotspot/share/memory/metaspace/metaspaceReporter.cpp

Print this page

 22  * questions.
 23  *
 24  */
 25 
 26 #include "precompiled.hpp"
 27 #include "cds/cdsConfig.hpp"
 28 #include "classfile/classLoaderData.hpp"
 29 #include "classfile/classLoaderDataGraph.hpp"
 30 #include "memory/metaspace.hpp"
 31 #include "memory/metaspace/chunkHeaderPool.hpp"
 32 #include "memory/metaspace/chunkManager.hpp"
 33 #include "memory/metaspace/internalStats.hpp"
 34 #include "memory/metaspace/metaspaceCommon.hpp"
 35 #include "memory/metaspace/metaspaceReporter.hpp"
 36 #include "memory/metaspace/metaspaceSettings.hpp"
 37 #include "memory/metaspace/metaspaceStatistics.hpp"
 38 #include "memory/metaspace/printCLDMetaspaceInfoClosure.hpp"
 39 #include "memory/metaspace/runningCounters.hpp"
 40 #include "memory/metaspace/virtualSpaceList.hpp"
 41 #include "memory/metaspaceUtils.hpp"

 42 #include "runtime/os.hpp"
 43 
 44 namespace metaspace {
 45 
 46 static const char* describe_spacetype(Metaspace::MetaspaceType st) {
 47   const char* s = nullptr;
 48   switch (st) {
 49     case Metaspace::StandardMetaspaceType: s = "Standard"; break;
 50     case Metaspace::BootMetaspaceType: s = "Boot"; break;
 51     case Metaspace::ClassMirrorHolderMetaspaceType: s = "ClassMirrorHolder"; break;
 52     case Metaspace::ReflectionMetaspaceType: s = "Reflection"; break;
 53     default: ShouldNotReachHere();
 54   }
 55   return s;
 56 }
 57 
 58 static void print_vs(outputStream* out, size_t scale) {
 59   const size_t reserved_nc = RunningCounters::reserved_words_nonclass();
 60   const size_t committed_nc = RunningCounters::committed_words_nonclass();
 61   const int num_nodes_nc = VirtualSpaceList::vslist_nonclass()->num_nodes();

101     out->print("unlimited");
102   } else {
103     print_human_readable_size(out, MaxMetaspaceSize, scale);
104   }
105   out->cr();
106   if (Metaspace::using_class_space()) {
107     out->print("CompressedClassSpaceSize: ");
108     print_human_readable_size(out, CompressedClassSpaceSize, scale);
109   } else {
110     out->print("No class space");
111   }
112   out->cr();
113   out->print("Initial GC threshold: ");
114   print_human_readable_size(out, MetaspaceSize, scale);
115   out->cr();
116   out->print("Current GC threshold: ");
117   print_human_readable_size(out, MetaspaceGC::capacity_until_GC(), scale);
118   out->cr();
119   out->print_cr("CDS: %s", (CDSConfig::is_using_archive() ? "on" : (CDSConfig::is_dumping_static_archive() ? "dump" : "off")));
120   Settings::print_on(out);



121 }
122 
123 // This will print out a basic metaspace usage report but
124 // unlike print_report() is guaranteed not to lock or to walk the CLDG.
125 void MetaspaceReporter::print_basic_report(outputStream* out, size_t scale) {
126   if (!Metaspace::initialized()) {
127     out->print_cr("Metaspace not yet initialized.");
128     return;
129   }
130   out->cr();
131   out->print_cr("Usage:");
132   if (Metaspace::using_class_space()) {
133     out->print("  Non-class:  ");
134   }
135 
136   // Note: since we want to purely rely on counters, without any locking or walking the CLDG,
137   // for Usage stats (statistics over in-use chunks) all we can print is the
138   // used words. We cannot print committed areas, or free/waste areas, of in-use chunks require
139   // walking.
140   const size_t used_nc = MetaspaceUtils::used_words(Metaspace::NonClassType);

308       out->print_cr("   Non-Class:");
309     }
310     ChunkManager::chunkmanager_nonclass()->print_on(out);
311     out->cr();
312     if (Metaspace::using_class_space()) {
313       out->print_cr("       Class:");
314       ChunkManager::chunkmanager_class()->print_on(out);
315       out->cr();
316     }
317   }
318   out->cr();
319 
320 
321   //////////// Waste section ///////////////////////////
322   // As a convenience, print a summary of common waste.
323   out->cr();
324   out->print("Waste (unused committed space):");
325   // For all wastages, print percentages from total. As total use the total size of memory committed for metaspace.
326   const size_t committed_words = RunningCounters::committed_words();
327 
328   out->print("(percentages refer to total committed size ");
329   print_scaled_words(out, committed_words, scale);
330   out->print_cr("):");
331 
332   // Print waste for in-use chunks.
333   InUseChunkStats ucs_nonclass = cl._stats_total._arena_stats_nonclass.totals();
334   InUseChunkStats ucs_class = cl._stats_total._arena_stats_class.totals();
335   const size_t waste_in_chunks_in_use = ucs_nonclass._waste_words + ucs_class._waste_words;
336   const size_t free_in_chunks_in_use = ucs_nonclass._free_words + ucs_class._free_words;
337 
338   out->print("        Waste in chunks in use: ");
339   print_scaled_words_and_percentage(out, waste_in_chunks_in_use, committed_words, scale, 6);
340   out->cr();
341   out->print("        Free in chunks in use: ");
342   print_scaled_words_and_percentage(out, free_in_chunks_in_use, committed_words, scale, 6);
343   out->cr();
344 
345   // Print waste in free chunks.
346   const size_t committed_in_free_chunks = total_cm_stat.total_committed_word_size();
347   out->print("                In free chunks: ");
348   print_scaled_words_and_percentage(out, committed_in_free_chunks, committed_words, scale, 6);

 22  * questions.
 23  *
 24  */
 25 
 26 #include "precompiled.hpp"
 27 #include "cds/cdsConfig.hpp"
 28 #include "classfile/classLoaderData.hpp"
 29 #include "classfile/classLoaderDataGraph.hpp"
 30 #include "memory/metaspace.hpp"
 31 #include "memory/metaspace/chunkHeaderPool.hpp"
 32 #include "memory/metaspace/chunkManager.hpp"
 33 #include "memory/metaspace/internalStats.hpp"
 34 #include "memory/metaspace/metaspaceCommon.hpp"
 35 #include "memory/metaspace/metaspaceReporter.hpp"
 36 #include "memory/metaspace/metaspaceSettings.hpp"
 37 #include "memory/metaspace/metaspaceStatistics.hpp"
 38 #include "memory/metaspace/printCLDMetaspaceInfoClosure.hpp"
 39 #include "memory/metaspace/runningCounters.hpp"
 40 #include "memory/metaspace/virtualSpaceList.hpp"
 41 #include "memory/metaspaceUtils.hpp"
 42 #include "oops/compressedKlass.hpp"
 43 #include "runtime/os.hpp"
 44 
 45 namespace metaspace {
 46 
 47 static const char* describe_spacetype(Metaspace::MetaspaceType st) {
 48   const char* s = nullptr;
 49   switch (st) {
 50     case Metaspace::StandardMetaspaceType: s = "Standard"; break;
 51     case Metaspace::BootMetaspaceType: s = "Boot"; break;
 52     case Metaspace::ClassMirrorHolderMetaspaceType: s = "ClassMirrorHolder"; break;
 53     case Metaspace::ReflectionMetaspaceType: s = "Reflection"; break;
 54     default: ShouldNotReachHere();
 55   }
 56   return s;
 57 }
 58 
 59 static void print_vs(outputStream* out, size_t scale) {
 60   const size_t reserved_nc = RunningCounters::reserved_words_nonclass();
 61   const size_t committed_nc = RunningCounters::committed_words_nonclass();
 62   const int num_nodes_nc = VirtualSpaceList::vslist_nonclass()->num_nodes();

102     out->print("unlimited");
103   } else {
104     print_human_readable_size(out, MaxMetaspaceSize, scale);
105   }
106   out->cr();
107   if (Metaspace::using_class_space()) {
108     out->print("CompressedClassSpaceSize: ");
109     print_human_readable_size(out, CompressedClassSpaceSize, scale);
110   } else {
111     out->print("No class space");
112   }
113   out->cr();
114   out->print("Initial GC threshold: ");
115   print_human_readable_size(out, MetaspaceSize, scale);
116   out->cr();
117   out->print("Current GC threshold: ");
118   print_human_readable_size(out, MetaspaceGC::capacity_until_GC(), scale);
119   out->cr();
120   out->print_cr("CDS: %s", (CDSConfig::is_using_archive() ? "on" : (CDSConfig::is_dumping_static_archive() ? "dump" : "off")));
121   Settings::print_on(out);
122 #ifdef _LP64
123   CompressedKlassPointers::print_mode(out);
124 #endif
125 }
126 
127 // This will print out a basic metaspace usage report but
128 // unlike print_report() is guaranteed not to lock or to walk the CLDG.
129 void MetaspaceReporter::print_basic_report(outputStream* out, size_t scale) {
130   if (!Metaspace::initialized()) {
131     out->print_cr("Metaspace not yet initialized.");
132     return;
133   }
134   out->cr();
135   out->print_cr("Usage:");
136   if (Metaspace::using_class_space()) {
137     out->print("  Non-class:  ");
138   }
139 
140   // Note: since we want to purely rely on counters, without any locking or walking the CLDG,
141   // for Usage stats (statistics over in-use chunks) all we can print is the
142   // used words. We cannot print committed areas, or free/waste areas, of in-use chunks require
143   // walking.
144   const size_t used_nc = MetaspaceUtils::used_words(Metaspace::NonClassType);

312       out->print_cr("   Non-Class:");
313     }
314     ChunkManager::chunkmanager_nonclass()->print_on(out);
315     out->cr();
316     if (Metaspace::using_class_space()) {
317       out->print_cr("       Class:");
318       ChunkManager::chunkmanager_class()->print_on(out);
319       out->cr();
320     }
321   }
322   out->cr();
323 
324 
325   //////////// Waste section ///////////////////////////
326   // As a convenience, print a summary of common waste.
327   out->cr();
328   out->print("Waste (unused committed space):");
329   // For all wastages, print percentages from total. As total use the total size of memory committed for metaspace.
330   const size_t committed_words = RunningCounters::committed_words();
331 
332   out->print(" (percentages refer to total committed size ");
333   print_scaled_words(out, committed_words, scale);
334   out->print_cr("):");
335 
336   // Print waste for in-use chunks.
337   InUseChunkStats ucs_nonclass = cl._stats_total._arena_stats_nonclass.totals();
338   InUseChunkStats ucs_class = cl._stats_total._arena_stats_class.totals();
339   const size_t waste_in_chunks_in_use = ucs_nonclass._waste_words + ucs_class._waste_words;
340   const size_t free_in_chunks_in_use = ucs_nonclass._free_words + ucs_class._free_words;
341 
342   out->print("        Waste in chunks in use: ");
343   print_scaled_words_and_percentage(out, waste_in_chunks_in_use, committed_words, scale, 6);
344   out->cr();
345   out->print("        Free in chunks in use: ");
346   print_scaled_words_and_percentage(out, free_in_chunks_in_use, committed_words, scale, 6);
347   out->cr();
348 
349   // Print waste in free chunks.
350   const size_t committed_in_free_chunks = total_cm_stat.total_committed_word_size();
351   out->print("                In free chunks: ");
352   print_scaled_words_and_percentage(out, committed_in_free_chunks, committed_words, scale, 6);
< prev index next >