src/share/vm/gc_implementation/g1/concurrentMark.cpp

Print this page
rev 4803 : imported patch thomas-comments-2


4499 #define G1PPRL_TYPE_FORMAT            "   %-4s"
4500 #define G1PPRL_TYPE_H_FORMAT          "   %4s"
4501 #define G1PPRL_BYTE_FORMAT            "  "SIZE_FORMAT_W(9)
4502 #define G1PPRL_BYTE_H_FORMAT          "  %9s"
4503 #define G1PPRL_DOUBLE_FORMAT          "  %14.1f"
4504 #define G1PPRL_DOUBLE_H_FORMAT        "  %14s"
4505 
4506 // For summary info
4507 #define G1PPRL_SUM_ADDR_FORMAT(tag)    "  "tag":"G1PPRL_ADDR_BASE_FORMAT
4508 #define G1PPRL_SUM_BYTE_FORMAT(tag)    "  "tag": "SIZE_FORMAT
4509 #define G1PPRL_SUM_MB_FORMAT(tag)      "  "tag": %1.2f MB"
4510 #define G1PPRL_SUM_MB_PERC_FORMAT(tag) G1PPRL_SUM_MB_FORMAT(tag)" / %1.2f %%"
4511 
4512 G1PrintRegionLivenessInfoClosure::
4513 G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name)
4514   : _out(out),
4515     _total_used_bytes(0), _total_capacity_bytes(0),
4516     _total_prev_live_bytes(0), _total_next_live_bytes(0),
4517     _hum_used_bytes(0), _hum_capacity_bytes(0),
4518     _hum_prev_live_bytes(0), _hum_next_live_bytes(0),
4519     _total_remset_bytes(0) {
4520   G1CollectedHeap* g1h = G1CollectedHeap::heap();
4521   MemRegion g1_committed = g1h->g1_committed();
4522   MemRegion g1_reserved = g1h->g1_reserved();
4523   double now = os::elapsedTime();
4524 
4525   // Print the header of the output.
4526   _out->cr();
4527   _out->print_cr(G1PPRL_LINE_PREFIX" PHASE %s @ %1.3f", phase_name, now);
4528   _out->print_cr(G1PPRL_LINE_PREFIX" HEAP"
4529                  G1PPRL_SUM_ADDR_FORMAT("committed")
4530                  G1PPRL_SUM_ADDR_FORMAT("reserved")
4531                  G1PPRL_SUM_BYTE_FORMAT("region-size"),
4532                  g1_committed.start(), g1_committed.end(),
4533                  g1_reserved.start(), g1_reserved.end(),
4534                  HeapRegion::GrainBytes);
4535   _out->print_cr(G1PPRL_LINE_PREFIX);
4536   _out->print_cr(G1PPRL_LINE_PREFIX
4537                 G1PPRL_TYPE_H_FORMAT
4538                 G1PPRL_ADDR_BASE_H_FORMAT
4539                 G1PPRL_BYTE_H_FORMAT
4540                 G1PPRL_BYTE_H_FORMAT
4541                 G1PPRL_BYTE_H_FORMAT
4542                 G1PPRL_DOUBLE_H_FORMAT

4543                 G1PPRL_BYTE_H_FORMAT,
4544                 "type", "address-range",
4545                 "used", "prev-live", "next-live", "gc-eff", "remset");

4546   _out->print_cr(G1PPRL_LINE_PREFIX
4547                 G1PPRL_TYPE_H_FORMAT
4548                 G1PPRL_ADDR_BASE_H_FORMAT
4549                 G1PPRL_BYTE_H_FORMAT
4550                 G1PPRL_BYTE_H_FORMAT
4551                 G1PPRL_BYTE_H_FORMAT
4552                 G1PPRL_DOUBLE_H_FORMAT

4553                 G1PPRL_BYTE_H_FORMAT,
4554                 "", "",
4555                 "(bytes)", "(bytes)", "(bytes)", "(bytes/ms)", "(bytes)");

4556 }
4557 
4558 // It takes as a parameter a reference to one of the _hum_* fields, it
4559 // deduces the corresponding value for a region in a humongous region
4560 // series (either the region size, or what's left if the _hum_* field
4561 // is < the region size), and updates the _hum_* field accordingly.
4562 size_t G1PrintRegionLivenessInfoClosure::get_hum_bytes(size_t* hum_bytes) {
4563   size_t bytes = 0;
4564   // The > 0 check is to deal with the prev and next live bytes which
4565   // could be 0.
4566   if (*hum_bytes > 0) {
4567     bytes = MIN2(HeapRegion::GrainBytes, *hum_bytes);
4568     *hum_bytes -= bytes;
4569   }
4570   return bytes;
4571 }
4572 
4573 // It deduces the values for a region in a humongous region series
4574 // from the _hum_* fields and updates those accordingly. It assumes
4575 // that that _hum_* fields have already been set up from the "starts


4578                                                      size_t* capacity_bytes,
4579                                                      size_t* prev_live_bytes,
4580                                                      size_t* next_live_bytes) {
4581   assert(_hum_used_bytes > 0 && _hum_capacity_bytes > 0, "pre-condition");
4582   *used_bytes      = get_hum_bytes(&_hum_used_bytes);
4583   *capacity_bytes  = get_hum_bytes(&_hum_capacity_bytes);
4584   *prev_live_bytes = get_hum_bytes(&_hum_prev_live_bytes);
4585   *next_live_bytes = get_hum_bytes(&_hum_next_live_bytes);
4586 }
4587 
4588 bool G1PrintRegionLivenessInfoClosure::doHeapRegion(HeapRegion* r) {
4589   const char* type = "";
4590   HeapWord* bottom       = r->bottom();
4591   HeapWord* end          = r->end();
4592   size_t capacity_bytes  = r->capacity();
4593   size_t used_bytes      = r->used();
4594   size_t prev_live_bytes = r->live_bytes();
4595   size_t next_live_bytes = r->next_live_bytes();
4596   double gc_eff          = r->gc_efficiency();
4597   size_t remset_bytes    = r->rem_set()->mem_size();


4598   if (r->used() == 0) {
4599     type = "FREE";
4600   } else if (r->is_survivor()) {
4601     type = "SURV";
4602   } else if (r->is_young()) {
4603     type = "EDEN";
4604   } else if (r->startsHumongous()) {
4605     type = "HUMS";
4606 
4607     assert(_hum_used_bytes == 0 && _hum_capacity_bytes == 0 &&
4608            _hum_prev_live_bytes == 0 && _hum_next_live_bytes == 0,
4609            "they should have been zeroed after the last time we used them");
4610     // Set up the _hum_* fields.
4611     _hum_capacity_bytes  = capacity_bytes;
4612     _hum_used_bytes      = used_bytes;
4613     _hum_prev_live_bytes = prev_live_bytes;
4614     _hum_next_live_bytes = next_live_bytes;
4615     get_hum_bytes(&used_bytes, &capacity_bytes,
4616                   &prev_live_bytes, &next_live_bytes);
4617     end = bottom + HeapRegion::GrainWords;
4618   } else if (r->continuesHumongous()) {
4619     type = "HUMC";
4620     get_hum_bytes(&used_bytes, &capacity_bytes,
4621                   &prev_live_bytes, &next_live_bytes);
4622     assert(end == bottom + HeapRegion::GrainWords, "invariant");
4623   } else {
4624     type = "OLD";
4625   }
4626 
4627   _total_used_bytes      += used_bytes;
4628   _total_capacity_bytes  += capacity_bytes;
4629   _total_prev_live_bytes += prev_live_bytes;
4630   _total_next_live_bytes += next_live_bytes;
4631   _total_remset_bytes    += remset_bytes;

4632 
4633   // Print a line for this particular region.
4634   _out->print_cr(G1PPRL_LINE_PREFIX
4635                  G1PPRL_TYPE_FORMAT
4636                  G1PPRL_ADDR_BASE_FORMAT
4637                  G1PPRL_BYTE_FORMAT
4638                  G1PPRL_BYTE_FORMAT
4639                  G1PPRL_BYTE_FORMAT
4640                  G1PPRL_DOUBLE_FORMAT

4641                  G1PPRL_BYTE_FORMAT,
4642                  type, bottom, end,
4643                  used_bytes, prev_live_bytes, next_live_bytes, gc_eff , remset_bytes);

4644 
4645   return false;
4646 }
4647 
4648 G1PrintRegionLivenessInfoClosure::~G1PrintRegionLivenessInfoClosure() {
4649   // add static memory usages to remembered set sizes
4650   _total_remset_bytes += HeapRegionRemSet::fl_mem_size() + HeapRegionRemSet::static_mem_size();
4651   // Print the footer of the output.
4652   _out->print_cr(G1PPRL_LINE_PREFIX);
4653   _out->print_cr(G1PPRL_LINE_PREFIX
4654                  " SUMMARY"
4655                  G1PPRL_SUM_MB_FORMAT("capacity")
4656                  G1PPRL_SUM_MB_PERC_FORMAT("used")
4657                  G1PPRL_SUM_MB_PERC_FORMAT("prev-live")
4658                  G1PPRL_SUM_MB_PERC_FORMAT("next-live")
4659                  G1PPRL_SUM_MB_FORMAT("remset"),

4660                  bytes_to_mb(_total_capacity_bytes),
4661                  bytes_to_mb(_total_used_bytes),
4662                  perc(_total_used_bytes, _total_capacity_bytes),
4663                  bytes_to_mb(_total_prev_live_bytes),
4664                  perc(_total_prev_live_bytes, _total_capacity_bytes),
4665                  bytes_to_mb(_total_next_live_bytes),
4666                  perc(_total_next_live_bytes, _total_capacity_bytes),
4667                  bytes_to_mb(_total_remset_bytes));

4668   _out->cr();
4669 }


4499 #define G1PPRL_TYPE_FORMAT            "   %-4s"
4500 #define G1PPRL_TYPE_H_FORMAT          "   %4s"
4501 #define G1PPRL_BYTE_FORMAT            "  "SIZE_FORMAT_W(9)
4502 #define G1PPRL_BYTE_H_FORMAT          "  %9s"
4503 #define G1PPRL_DOUBLE_FORMAT          "  %14.1f"
4504 #define G1PPRL_DOUBLE_H_FORMAT        "  %14s"
4505 
4506 // For summary info
4507 #define G1PPRL_SUM_ADDR_FORMAT(tag)    "  "tag":"G1PPRL_ADDR_BASE_FORMAT
4508 #define G1PPRL_SUM_BYTE_FORMAT(tag)    "  "tag": "SIZE_FORMAT
4509 #define G1PPRL_SUM_MB_FORMAT(tag)      "  "tag": %1.2f MB"
4510 #define G1PPRL_SUM_MB_PERC_FORMAT(tag) G1PPRL_SUM_MB_FORMAT(tag)" / %1.2f %%"
4511 
4512 G1PrintRegionLivenessInfoClosure::
4513 G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name)
4514   : _out(out),
4515     _total_used_bytes(0), _total_capacity_bytes(0),
4516     _total_prev_live_bytes(0), _total_next_live_bytes(0),
4517     _hum_used_bytes(0), _hum_capacity_bytes(0),
4518     _hum_prev_live_bytes(0), _hum_next_live_bytes(0),
4519     _total_remset_bytes(0), _total_strong_code_roots_bytes(0) {
4520   G1CollectedHeap* g1h = G1CollectedHeap::heap();
4521   MemRegion g1_committed = g1h->g1_committed();
4522   MemRegion g1_reserved = g1h->g1_reserved();
4523   double now = os::elapsedTime();
4524 
4525   // Print the header of the output.
4526   _out->cr();
4527   _out->print_cr(G1PPRL_LINE_PREFIX" PHASE %s @ %1.3f", phase_name, now);
4528   _out->print_cr(G1PPRL_LINE_PREFIX" HEAP"
4529                  G1PPRL_SUM_ADDR_FORMAT("committed")
4530                  G1PPRL_SUM_ADDR_FORMAT("reserved")
4531                  G1PPRL_SUM_BYTE_FORMAT("region-size"),
4532                  g1_committed.start(), g1_committed.end(),
4533                  g1_reserved.start(), g1_reserved.end(),
4534                  HeapRegion::GrainBytes);
4535   _out->print_cr(G1PPRL_LINE_PREFIX);
4536   _out->print_cr(G1PPRL_LINE_PREFIX
4537                 G1PPRL_TYPE_H_FORMAT
4538                 G1PPRL_ADDR_BASE_H_FORMAT
4539                 G1PPRL_BYTE_H_FORMAT
4540                 G1PPRL_BYTE_H_FORMAT
4541                 G1PPRL_BYTE_H_FORMAT
4542                 G1PPRL_DOUBLE_H_FORMAT
4543                 G1PPRL_BYTE_H_FORMAT
4544                 G1PPRL_BYTE_H_FORMAT,
4545                 "type", "address-range",
4546                 "used", "prev-live", "next-live", "gc-eff",
4547                 "remset", "code-roots");
4548   _out->print_cr(G1PPRL_LINE_PREFIX
4549                 G1PPRL_TYPE_H_FORMAT
4550                 G1PPRL_ADDR_BASE_H_FORMAT
4551                 G1PPRL_BYTE_H_FORMAT
4552                 G1PPRL_BYTE_H_FORMAT
4553                 G1PPRL_BYTE_H_FORMAT
4554                 G1PPRL_DOUBLE_H_FORMAT
4555                 G1PPRL_BYTE_H_FORMAT
4556                 G1PPRL_BYTE_H_FORMAT,
4557                 "", "",
4558                 "(bytes)", "(bytes)", "(bytes)", "(bytes/ms)",
4559                 "(bytes)", "(bytes)");
4560 }
4561 
4562 // It takes as a parameter a reference to one of the _hum_* fields, it
4563 // deduces the corresponding value for a region in a humongous region
4564 // series (either the region size, or what's left if the _hum_* field
4565 // is < the region size), and updates the _hum_* field accordingly.
4566 size_t G1PrintRegionLivenessInfoClosure::get_hum_bytes(size_t* hum_bytes) {
4567   size_t bytes = 0;
4568   // The > 0 check is to deal with the prev and next live bytes which
4569   // could be 0.
4570   if (*hum_bytes > 0) {
4571     bytes = MIN2(HeapRegion::GrainBytes, *hum_bytes);
4572     *hum_bytes -= bytes;
4573   }
4574   return bytes;
4575 }
4576 
4577 // It deduces the values for a region in a humongous region series
4578 // from the _hum_* fields and updates those accordingly. It assumes
4579 // that that _hum_* fields have already been set up from the "starts


4582                                                      size_t* capacity_bytes,
4583                                                      size_t* prev_live_bytes,
4584                                                      size_t* next_live_bytes) {
4585   assert(_hum_used_bytes > 0 && _hum_capacity_bytes > 0, "pre-condition");
4586   *used_bytes      = get_hum_bytes(&_hum_used_bytes);
4587   *capacity_bytes  = get_hum_bytes(&_hum_capacity_bytes);
4588   *prev_live_bytes = get_hum_bytes(&_hum_prev_live_bytes);
4589   *next_live_bytes = get_hum_bytes(&_hum_next_live_bytes);
4590 }
4591 
4592 bool G1PrintRegionLivenessInfoClosure::doHeapRegion(HeapRegion* r) {
4593   const char* type = "";
4594   HeapWord* bottom       = r->bottom();
4595   HeapWord* end          = r->end();
4596   size_t capacity_bytes  = r->capacity();
4597   size_t used_bytes      = r->used();
4598   size_t prev_live_bytes = r->live_bytes();
4599   size_t next_live_bytes = r->next_live_bytes();
4600   double gc_eff          = r->gc_efficiency();
4601   size_t remset_bytes    = r->rem_set()->mem_size();
4602   size_t strong_code_roots_bytes = r->rem_set()->strong_code_roots_mem_size();
4603 
4604   if (r->used() == 0) {
4605     type = "FREE";
4606   } else if (r->is_survivor()) {
4607     type = "SURV";
4608   } else if (r->is_young()) {
4609     type = "EDEN";
4610   } else if (r->startsHumongous()) {
4611     type = "HUMS";
4612 
4613     assert(_hum_used_bytes == 0 && _hum_capacity_bytes == 0 &&
4614            _hum_prev_live_bytes == 0 && _hum_next_live_bytes == 0,
4615            "they should have been zeroed after the last time we used them");
4616     // Set up the _hum_* fields.
4617     _hum_capacity_bytes  = capacity_bytes;
4618     _hum_used_bytes      = used_bytes;
4619     _hum_prev_live_bytes = prev_live_bytes;
4620     _hum_next_live_bytes = next_live_bytes;
4621     get_hum_bytes(&used_bytes, &capacity_bytes,
4622                   &prev_live_bytes, &next_live_bytes);
4623     end = bottom + HeapRegion::GrainWords;
4624   } else if (r->continuesHumongous()) {
4625     type = "HUMC";
4626     get_hum_bytes(&used_bytes, &capacity_bytes,
4627                   &prev_live_bytes, &next_live_bytes);
4628     assert(end == bottom + HeapRegion::GrainWords, "invariant");
4629   } else {
4630     type = "OLD";
4631   }
4632 
4633   _total_used_bytes      += used_bytes;
4634   _total_capacity_bytes  += capacity_bytes;
4635   _total_prev_live_bytes += prev_live_bytes;
4636   _total_next_live_bytes += next_live_bytes;
4637   _total_remset_bytes    += remset_bytes;
4638   _total_strong_code_roots_bytes += strong_code_roots_bytes;
4639 
4640   // Print a line for this particular region.
4641   _out->print_cr(G1PPRL_LINE_PREFIX
4642                  G1PPRL_TYPE_FORMAT
4643                  G1PPRL_ADDR_BASE_FORMAT
4644                  G1PPRL_BYTE_FORMAT
4645                  G1PPRL_BYTE_FORMAT
4646                  G1PPRL_BYTE_FORMAT
4647                  G1PPRL_DOUBLE_FORMAT
4648                  G1PPRL_BYTE_FORMAT
4649                  G1PPRL_BYTE_FORMAT,
4650                  type, bottom, end,
4651                  used_bytes, prev_live_bytes, next_live_bytes, gc_eff,
4652                  remset_bytes, strong_code_roots_bytes);
4653 
4654   return false;
4655 }
4656 
4657 G1PrintRegionLivenessInfoClosure::~G1PrintRegionLivenessInfoClosure() {
4658   // add static memory usages to remembered set sizes
4659   _total_remset_bytes += HeapRegionRemSet::fl_mem_size() + HeapRegionRemSet::static_mem_size();
4660   // Print the footer of the output.
4661   _out->print_cr(G1PPRL_LINE_PREFIX);
4662   _out->print_cr(G1PPRL_LINE_PREFIX
4663                  " SUMMARY"
4664                  G1PPRL_SUM_MB_FORMAT("capacity")
4665                  G1PPRL_SUM_MB_PERC_FORMAT("used")
4666                  G1PPRL_SUM_MB_PERC_FORMAT("prev-live")
4667                  G1PPRL_SUM_MB_PERC_FORMAT("next-live")
4668                  G1PPRL_SUM_MB_FORMAT("remset")
4669                  G1PPRL_SUM_MB_FORMAT("code-roots"),
4670                  bytes_to_mb(_total_capacity_bytes),
4671                  bytes_to_mb(_total_used_bytes),
4672                  perc(_total_used_bytes, _total_capacity_bytes),
4673                  bytes_to_mb(_total_prev_live_bytes),
4674                  perc(_total_prev_live_bytes, _total_capacity_bytes),
4675                  bytes_to_mb(_total_next_live_bytes),
4676                  perc(_total_next_live_bytes, _total_capacity_bytes),
4677                  bytes_to_mb(_total_remset_bytes),
4678                  bytes_to_mb(_total_strong_code_roots_bytes));
4679   _out->cr();
4680 }