< prev index next >

src/hotspot/share/gc/g1/g1RemSetSummary.cpp

Print this page
rev 60637 : 8252141: Rename G1YoungRemSetSamplingThread to better reflect its purpose
Reviewed-by:


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1BarrierSet.hpp"
  27 #include "gc/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc/g1/g1ConcurrentRefine.hpp"
  29 #include "gc/g1/g1ConcurrentRefineThread.hpp"
  30 #include "gc/g1/g1DirtyCardQueue.hpp"
  31 #include "gc/g1/g1RemSet.hpp"
  32 #include "gc/g1/g1RemSetSummary.hpp"
  33 #include "gc/g1/g1YoungRemSetSamplingThread.hpp"
  34 #include "gc/g1/heapRegion.hpp"
  35 #include "gc/g1/heapRegionRemSet.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "memory/iterator.hpp"
  38 #include "runtime/thread.inline.hpp"
  39 
  40 void G1RemSetSummary::update() {
  41   class CollectData : public ThreadClosure {
  42     G1RemSetSummary* _summary;
  43     uint _counter;
  44   public:
  45     CollectData(G1RemSetSummary * summary) : _summary(summary),  _counter(0) {}
  46     virtual void do_thread(Thread* t) {
  47       G1ConcurrentRefineThread* crt = static_cast<G1ConcurrentRefineThread*>(t);
  48       _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
  49       _counter++;
  50     }
  51   } collector(this);
  52   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  53   g1h->concurrent_refine()->threads_do(&collector);
  54   _num_coarsenings = HeapRegionRemSet::n_coarsenings();
  55 
  56   set_sampling_thread_vtime(g1h->sampling_thread()->vtime_accum());
  57 }
  58 
  59 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
  60   assert(_rs_threads_vtimes != NULL, "just checking");
  61   assert(thread < _num_vtimes, "just checking");
  62   _rs_threads_vtimes[thread] = value;
  63 }
  64 
  65 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
  66   assert(_rs_threads_vtimes != NULL, "just checking");
  67   assert(thread < _num_vtimes, "just checking");
  68   return _rs_threads_vtimes[thread];
  69 }
  70 
  71 G1RemSetSummary::G1RemSetSummary(bool should_update) :
  72   _num_coarsenings(0),
  73   _num_vtimes(G1ConcurrentRefine::max_num_threads()),
  74   _rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)),
  75   _sampling_thread_vtime(0.0f) {
  76 
  77   memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
  78 
  79   if (should_update) {
  80     update();
  81   }
  82 }
  83 
  84 G1RemSetSummary::~G1RemSetSummary() {
  85   FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
  86 }
  87 
  88 void G1RemSetSummary::set(G1RemSetSummary* other) {
  89   assert(other != NULL, "just checking");
  90   assert(_num_vtimes == other->_num_vtimes, "just checking");
  91 
  92   _num_coarsenings = other->num_coarsenings();
  93 
  94   memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes);
  95 
  96   set_sampling_thread_vtime(other->sampling_thread_vtime());
  97 }
  98 
  99 void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
 100   assert(other != NULL, "just checking");
 101   assert(_num_vtimes == other->_num_vtimes, "just checking");
 102 
 103   _num_coarsenings = other->num_coarsenings() - _num_coarsenings;
 104 
 105   for (uint i = 0; i < _num_vtimes; i++) {
 106     set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i));
 107   }
 108 
 109   _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime;
 110 }
 111 
 112 class RegionTypeCounter {
 113 private:
 114   const char* _name;
 115 
 116   size_t _rs_mem_size;
 117   size_t _cards_occupied;
 118   size_t _amount;
 119 
 120   size_t _code_root_mem_size;
 121   size_t _code_root_elems;
 122 
 123   double rs_mem_size_percent_of(size_t total) {
 124     return percent_of(_rs_mem_size, total);
 125   }
 126 
 127   double cards_occupied_percent_of(size_t total) {
 128     return percent_of(_cards_occupied, total);
 129   }


 311     }
 312 
 313     out->print_cr("    Region with largest amount of code roots = " HR_FORMAT ", "
 314                   "size = " SIZE_FORMAT "%s, num_elems = " SIZE_FORMAT ".",
 315                   HR_FORMAT_PARAMS(max_code_root_mem_sz_region()),
 316                   byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
 317                   proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()),
 318                   max_code_root_rem_set->strong_code_roots_list_length());
 319   }
 320 };
 321 
 322 void G1RemSetSummary::print_on(outputStream* out) {
 323   out->print_cr("  Did " SIZE_FORMAT " coarsenings.", num_coarsenings());
 324   out->print_cr("  Concurrent refinement threads times (s)");
 325   out->print("     ");
 326   for (uint i = 0; i < _num_vtimes; i++) {
 327     out->print("    %5.2f", rs_thread_vtime(i));
 328   }
 329   out->cr();
 330   out->print_cr("  Concurrent sampling threads times (s)");
 331   out->print_cr("         %5.2f", sampling_thread_vtime());
 332 
 333   HRRSStatsIter blk;
 334   G1CollectedHeap::heap()->heap_region_iterate(&blk);
 335   blk.print_summary_on(out);
 336 }


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1BarrierSet.hpp"
  27 #include "gc/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc/g1/g1ConcurrentRefine.hpp"
  29 #include "gc/g1/g1ConcurrentRefineThread.hpp"
  30 #include "gc/g1/g1DirtyCardQueue.hpp"
  31 #include "gc/g1/g1RemSet.hpp"
  32 #include "gc/g1/g1RemSetSummary.hpp"
  33 #include "gc/g1/g1ServiceThread.hpp"
  34 #include "gc/g1/heapRegion.hpp"
  35 #include "gc/g1/heapRegionRemSet.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "memory/iterator.hpp"
  38 #include "runtime/thread.inline.hpp"
  39 
  40 void G1RemSetSummary::update() {
  41   class CollectData : public ThreadClosure {
  42     G1RemSetSummary* _summary;
  43     uint _counter;
  44   public:
  45     CollectData(G1RemSetSummary * summary) : _summary(summary),  _counter(0) {}
  46     virtual void do_thread(Thread* t) {
  47       G1ConcurrentRefineThread* crt = static_cast<G1ConcurrentRefineThread*>(t);
  48       _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
  49       _counter++;
  50     }
  51   } collector(this);
  52   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  53   g1h->concurrent_refine()->threads_do(&collector);
  54   _num_coarsenings = HeapRegionRemSet::n_coarsenings();
  55 
  56   set_service_thread_vtime(g1h->service_thread()->vtime_accum());
  57 }
  58 
  59 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
  60   assert(_rs_threads_vtimes != NULL, "just checking");
  61   assert(thread < _num_vtimes, "just checking");
  62   _rs_threads_vtimes[thread] = value;
  63 }
  64 
  65 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
  66   assert(_rs_threads_vtimes != NULL, "just checking");
  67   assert(thread < _num_vtimes, "just checking");
  68   return _rs_threads_vtimes[thread];
  69 }
  70 
  71 G1RemSetSummary::G1RemSetSummary(bool should_update) :
  72   _num_coarsenings(0),
  73   _num_vtimes(G1ConcurrentRefine::max_num_threads()),
  74   _rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)),
  75   _service_thread_vtime(0.0f) {
  76 
  77   memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
  78 
  79   if (should_update) {
  80     update();
  81   }
  82 }
  83 
  84 G1RemSetSummary::~G1RemSetSummary() {
  85   FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
  86 }
  87 
  88 void G1RemSetSummary::set(G1RemSetSummary* other) {
  89   assert(other != NULL, "just checking");
  90   assert(_num_vtimes == other->_num_vtimes, "just checking");
  91 
  92   _num_coarsenings = other->num_coarsenings();
  93 
  94   memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes);
  95 
  96   set_service_thread_vtime(other->service_thread_vtime());
  97 }
  98 
  99 void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
 100   assert(other != NULL, "just checking");
 101   assert(_num_vtimes == other->_num_vtimes, "just checking");
 102 
 103   _num_coarsenings = other->num_coarsenings() - _num_coarsenings;
 104 
 105   for (uint i = 0; i < _num_vtimes; i++) {
 106     set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i));
 107   }
 108 
 109   _service_thread_vtime = other->service_thread_vtime() - _service_thread_vtime;
 110 }
 111 
 112 class RegionTypeCounter {
 113 private:
 114   const char* _name;
 115 
 116   size_t _rs_mem_size;
 117   size_t _cards_occupied;
 118   size_t _amount;
 119 
 120   size_t _code_root_mem_size;
 121   size_t _code_root_elems;
 122 
 123   double rs_mem_size_percent_of(size_t total) {
 124     return percent_of(_rs_mem_size, total);
 125   }
 126 
 127   double cards_occupied_percent_of(size_t total) {
 128     return percent_of(_cards_occupied, total);
 129   }


 311     }
 312 
 313     out->print_cr("    Region with largest amount of code roots = " HR_FORMAT ", "
 314                   "size = " SIZE_FORMAT "%s, num_elems = " SIZE_FORMAT ".",
 315                   HR_FORMAT_PARAMS(max_code_root_mem_sz_region()),
 316                   byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
 317                   proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()),
 318                   max_code_root_rem_set->strong_code_roots_list_length());
 319   }
 320 };
 321 
 322 void G1RemSetSummary::print_on(outputStream* out) {
 323   out->print_cr("  Did " SIZE_FORMAT " coarsenings.", num_coarsenings());
 324   out->print_cr("  Concurrent refinement threads times (s)");
 325   out->print("     ");
 326   for (uint i = 0; i < _num_vtimes; i++) {
 327     out->print("    %5.2f", rs_thread_vtime(i));
 328   }
 329   out->cr();
 330   out->print_cr("  Concurrent sampling threads times (s)");
 331   out->print_cr("         %5.2f", service_thread_vtime());
 332 
 333   HRRSStatsIter blk;
 334   G1CollectedHeap::heap()->heap_region_iterate(&blk);
 335   blk.print_summary_on(out);
 336 }
< prev index next >