< prev index next >

src/hotspot/share/services/memReporter.cpp

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


 183     if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) {
 184       // We don't know how many arena chunks are in used, so don't report the count
 185       size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count();
 186       print_malloc_line(malloc_memory->malloc_size(), count);
 187     }
 188 
 189     if (amount_in_current_scale(virtual_memory->reserved()) > 0) {
 190       print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed());
 191     }
 192 
 193     if (amount_in_current_scale(malloc_memory->arena_size()) > 0) {
 194       print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count());
 195     }
 196 
 197     if (flag == mtNMT &&
 198       amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) {
 199       out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ",
 200         amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale);
 201     } else if (flag == mtClass) {
 202       // Metadata information
 203       report_metadata(Metaspace::NonClassType);
 204       if (Metaspace::using_class_space()) {
 205         report_metadata(Metaspace::ClassType);
 206       }
 207     }
 208     out->print_cr(" ");
 209   }
 210 }
 211 
 212 void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const {
 213   assert(type == Metaspace::NonClassType || type == Metaspace::ClassType,
 214     "Invalid metadata type");
 215   const char* name = (type == Metaspace::NonClassType) ?
 216     "Metadata:   " : "Class space:";
 217 
 218   outputStream* out = output();
 219   const char* scale = current_scale();
 220   size_t committed   = MetaspaceUtils::committed_bytes(type);
 221   size_t used = MetaspaceUtils::used_bytes(type);
 222   size_t free = (MetaspaceUtils::capacity_bytes(type) - used)
 223               + MetaspaceUtils::free_chunks_total_bytes(type)
 224               + MetaspaceUtils::free_in_vs_bytes(type);


 225 
 226   assert(committed >= used + free, "Sanity");
 227   size_t waste = committed - (used + free);
 228 
 229   out->print_cr("%27s (  %s)", " ", name);
 230   out->print("%27s (    ", " ");
 231   print_total(MetaspaceUtils::reserved_bytes(type), committed);
 232   out->print_cr(")");
 233   out->print_cr("%27s (    used=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(used), scale);
 234   out->print_cr("%27s (    free=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(free), scale);
 235   out->print_cr("%27s (    waste=" SIZE_FORMAT "%s =%2.2f%%)", " ", amount_in_current_scale(waste),
 236     scale, ((float)waste * 100)/committed);
 237 }
 238 
 239 void MemDetailReporter::report_detail() {
 240   // Start detail report
 241   outputStream* out = output();
 242   out->print_cr("Details:\n");
 243 
 244   report_malloc_sites();
 245   report_virtual_memory_allocation_sites();
 246 }
 247 
 248 void MemDetailReporter::report_malloc_sites() {
 249   MallocSiteIterator         malloc_itr = _baseline.malloc_sites(MemBaseline::by_size);
 250   if (malloc_itr.is_empty()) return;
 251 


 576 
 577       out->print("%27s (tracking overhead=" SIZE_FORMAT "%s", " ",
 578         amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale);
 579 
 580       long overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(),
 581            _early_baseline.malloc_tracking_overhead());
 582       if (overhead_diff != 0) {
 583         out->print(" %+ld%s", overhead_diff, scale);
 584       }
 585       out->print_cr(")");
 586     } else if (flag == mtClass) {
 587       assert(current_ms != NULL && early_ms != NULL, "Sanity");
 588       print_metaspace_diff(current_ms, early_ms);
 589     }
 590     out->print_cr(" ");
 591   }
 592 }
 593 
 594 void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms,
 595                                                   const MetaspaceSnapshot* early_ms) const {
 596   print_metaspace_diff(Metaspace::NonClassType, current_ms, early_ms);
 597   if (Metaspace::using_class_space()) {
 598     print_metaspace_diff(Metaspace::ClassType, current_ms, early_ms);
 599   }
 600 }
 601 
 602 void MemSummaryDiffReporter::print_metaspace_diff(Metaspace::MetadataType type,
 603                                                   const MetaspaceSnapshot* current_ms,
 604                                                   const MetaspaceSnapshot* early_ms) const {
 605   const char* name = (type == Metaspace::NonClassType) ?
 606     "Metadata:   " : "Class space:";
 607 
 608   outputStream* out = output();
 609   const char* scale = current_scale();
 610 
 611   out->print_cr("%27s (  %s)", " ", name);
 612   out->print("%27s (    ", " ");
 613   print_virtual_memory_diff(current_ms->reserved_in_bytes(type),
 614                             current_ms->committed_in_bytes(type),
 615                             early_ms->reserved_in_bytes(type),
 616                             early_ms->committed_in_bytes(type));
 617   out->print_cr(")");
 618 
 619   long diff_used = diff_in_current_scale(current_ms->used_in_bytes(type),
 620                                          early_ms->used_in_bytes(type));
 621   long diff_free = diff_in_current_scale(current_ms->free_in_bytes(type),
 622                                          early_ms->free_in_bytes(type));
 623 
 624   size_t current_waste = current_ms->committed_in_bytes(type)
 625     - (current_ms->used_in_bytes(type) + current_ms->free_in_bytes(type));
 626   size_t early_waste = early_ms->committed_in_bytes(type)
 627     - (early_ms->used_in_bytes(type) + early_ms->free_in_bytes(type));
 628   long diff_waste = diff_in_current_scale(current_waste, early_waste);
 629 
 630   // Diff used
 631   out->print("%27s (    used=" SIZE_FORMAT "%s", " ",
 632     amount_in_current_scale(current_ms->used_in_bytes(type)), scale);
 633   if (diff_used != 0) {
 634     out->print(" %+ld%s", diff_used, scale);
 635   }
 636   out->print_cr(")");
 637 
 638   // Diff free
 639   out->print("%27s (    free=" SIZE_FORMAT "%s", " ",
 640     amount_in_current_scale(current_ms->free_in_bytes(type)), scale);
 641   if (diff_free != 0) {
 642     out->print(" %+ld%s", diff_free, scale);
 643   }
 644   out->print_cr(")");
 645 
 646 
 647   // Diff waste
 648   out->print("%27s (    waste=" SIZE_FORMAT "%s =%2.2f%%", " ",
 649     amount_in_current_scale(current_waste), scale,
 650     ((float)current_waste * 100) / current_ms->committed_in_bytes(type));
 651   if (diff_waste != 0) {
 652     out->print(" %+ld%s", diff_waste, scale);
 653   }
 654   out->print_cr(")");
 655 }
 656 
 657 void MemDetailDiffReporter::report_diff() {
 658   MemSummaryDiffReporter::report_diff();
 659   diff_malloc_sites();
 660   diff_virtual_memory_sites();
 661 }
 662 
 663 void MemDetailDiffReporter::diff_malloc_sites() const {
 664   MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type);
 665   MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type);
 666 
 667   const MallocSite* early_site   = early_itr.next();
 668   const MallocSite* current_site = current_itr.next();
 669 
 670   while (early_site != NULL || current_site != NULL) {




 183     if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) {
 184       // We don't know how many arena chunks are in used, so don't report the count
 185       size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count();
 186       print_malloc_line(malloc_memory->malloc_size(), count);
 187     }
 188 
 189     if (amount_in_current_scale(virtual_memory->reserved()) > 0) {
 190       print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed());
 191     }
 192 
 193     if (amount_in_current_scale(malloc_memory->arena_size()) > 0) {
 194       print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count());
 195     }
 196 
 197     if (flag == mtNMT &&
 198       amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) {
 199       out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ",
 200         amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale);
 201     } else if (flag == mtClass) {
 202       // Metadata information
 203       report_metadata(metaspace::NonClassType);
 204       if (Metaspace::using_class_space()) {
 205         report_metadata(metaspace::ClassType);
 206       }
 207     }
 208     out->print_cr(" ");
 209   }
 210 }
 211 
 212 void MemSummaryReporter::report_metadata(metaspace::MetadataType mdType) const {
 213   DEBUG_ONLY(metaspace::check_valid_mdtype(mdType));
 214   const char* const name = metaspace::describe_mdtype(mdType);


 215 
 216   outputStream* out = output();
 217   const char* scale = current_scale();
 218   size_t committed   = MetaspaceUtils::committed_bytes(mdType);
 219   size_t used = MetaspaceUtils::used_bytes(mdType);
 220   size_t free = 0; //
 221       // TODO think this thru. What is free in this context?
 222       // (MetaspaceUtils::capacity_bytes(type) - used)
 223   //         + MetaspaceUtils::free_chunks_total_bytes(type)
 224   //          + MetaspaceUtils::free_in_vs_bytes(type);
 225 
 226   assert(committed >= used + free, "Sanity");
 227   size_t waste = committed - (used + free);
 228 
 229   out->print_cr("%27s (  %s)", " ", name);
 230   out->print("%27s (    ", " ");
 231   print_total(MetaspaceUtils::reserved_bytes(mdType), committed);
 232   out->print_cr(")");
 233   out->print_cr("%27s (    used=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(used), scale);
 234   out->print_cr("%27s (    free=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(free), scale);
 235   out->print_cr("%27s (    waste=" SIZE_FORMAT "%s =%2.2f%%)", " ", amount_in_current_scale(waste),
 236     scale, ((float)waste * 100)/committed);
 237 }
 238 
 239 void MemDetailReporter::report_detail() {
 240   // Start detail report
 241   outputStream* out = output();
 242   out->print_cr("Details:\n");
 243 
 244   report_malloc_sites();
 245   report_virtual_memory_allocation_sites();
 246 }
 247 
 248 void MemDetailReporter::report_malloc_sites() {
 249   MallocSiteIterator         malloc_itr = _baseline.malloc_sites(MemBaseline::by_size);
 250   if (malloc_itr.is_empty()) return;
 251 


 576 
 577       out->print("%27s (tracking overhead=" SIZE_FORMAT "%s", " ",
 578         amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale);
 579 
 580       long overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(),
 581            _early_baseline.malloc_tracking_overhead());
 582       if (overhead_diff != 0) {
 583         out->print(" %+ld%s", overhead_diff, scale);
 584       }
 585       out->print_cr(")");
 586     } else if (flag == mtClass) {
 587       assert(current_ms != NULL && early_ms != NULL, "Sanity");
 588       print_metaspace_diff(current_ms, early_ms);
 589     }
 590     out->print_cr(" ");
 591   }
 592 }
 593 
 594 void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms,
 595                                                   const MetaspaceSnapshot* early_ms) const {
 596   print_metaspace_diff(metaspace::NonClassType, current_ms, early_ms);
 597   if (Metaspace::using_class_space()) {
 598     print_metaspace_diff(metaspace::ClassType, current_ms, early_ms);
 599   }
 600 }
 601 
 602 void MemSummaryDiffReporter::print_metaspace_diff(metaspace::MetadataType mdType,
 603                                                   const MetaspaceSnapshot* current_ms,
 604                                                   const MetaspaceSnapshot* early_ms) const {
 605   DEBUG_ONLY(metaspace::check_valid_mdtype(mdType));
 606   const char* const name = metaspace::describe_mdtype(mdType);
 607 
 608   outputStream* out = output();
 609   const char* scale = current_scale();
 610 
 611   out->print_cr("%27s (  %s)", " ", name);
 612   out->print("%27s (    ", " ");
 613   print_virtual_memory_diff(current_ms->reserved_in_bytes(mdType),
 614                             current_ms->committed_in_bytes(mdType),
 615                             early_ms->reserved_in_bytes(mdType),
 616                             early_ms->committed_in_bytes(mdType));
 617   out->print_cr(")");
 618 
 619   long diff_used = diff_in_current_scale(current_ms->used_in_bytes(mdType),
 620                                          early_ms->used_in_bytes(mdType));
 621   long diff_free = diff_in_current_scale(current_ms->free_in_bytes(mdType),
 622                                          early_ms->free_in_bytes(mdType));
 623 
 624   size_t current_waste = current_ms->committed_in_bytes(mdType)
 625     - (current_ms->used_in_bytes(mdType) + current_ms->free_in_bytes(mdType));
 626   size_t early_waste = early_ms->committed_in_bytes(mdType)
 627     - (early_ms->used_in_bytes(mdType) + early_ms->free_in_bytes(mdType));
 628   long diff_waste = diff_in_current_scale(current_waste, early_waste);
 629 
 630   // Diff used
 631   out->print("%27s (    used=" SIZE_FORMAT "%s", " ",
 632     amount_in_current_scale(current_ms->used_in_bytes(mdType)), scale);
 633   if (diff_used != 0) {
 634     out->print(" %+ld%s", diff_used, scale);
 635   }
 636   out->print_cr(")");
 637 
 638   // Diff free
 639   out->print("%27s (    free=" SIZE_FORMAT "%s", " ",
 640     amount_in_current_scale(current_ms->free_in_bytes(mdType)), scale);
 641   if (diff_free != 0) {
 642     out->print(" %+ld%s", diff_free, scale);
 643   }
 644   out->print_cr(")");
 645 
 646 
 647   // Diff waste
 648   out->print("%27s (    waste=" SIZE_FORMAT "%s =%2.2f%%", " ",
 649     amount_in_current_scale(current_waste), scale,
 650     ((float)current_waste * 100) / current_ms->committed_in_bytes(mdType));
 651   if (diff_waste != 0) {
 652     out->print(" %+ld%s", diff_waste, scale);
 653   }
 654   out->print_cr(")");
 655 }
 656 
 657 void MemDetailDiffReporter::report_diff() {
 658   MemSummaryDiffReporter::report_diff();
 659   diff_malloc_sites();
 660   diff_virtual_memory_sites();
 661 }
 662 
 663 void MemDetailDiffReporter::diff_malloc_sites() const {
 664   MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type);
 665   MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type);
 666 
 667   const MallocSite* early_site   = early_itr.next();
 668   const MallocSite* current_site = current_itr.next();
 669 
 670   while (early_site != NULL || current_site != NULL) {


< prev index next >