src/share/vm/gc_implementation/shared/gcTrace.cpp

Print this page
rev 4462 : 8012086: The object count event should only send events for instances occupying more than 0.5% of the heap


  74   send_garbage_collection_event();
  75 }
  76 
  77 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) {
  78   assert_set_gc_id();
  79 
  80   report_gc_end_impl(timestamp, time_partitions);
  81 
  82   _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
  83 }
  84 
  85 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
  86   assert_set_gc_id();
  87 
  88   send_reference_stats_event(REF_SOFT, rps.soft_count());
  89   send_reference_stats_event(REF_WEAK, rps.weak_count());
  90   send_reference_stats_event(REF_FINAL, rps.final_count());
  91   send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
  92 }
  93 
  94 class ObjectCountEventSenderClosure : public KlassInfoClosure {
  95   GCTracer* _gc_tracer;
  96  public:
  97   ObjectCountEventSenderClosure(GCTracer* gc_tracer) : _gc_tracer(gc_tracer) {}
  98  private:
  99   void do_cinfo(KlassInfoEntry* entry) {

 100     _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(),
 101                                                  entry->words() * BytesPerWord);
 102   }
 103 };















 104 
 105 void GCTracer::report_object_count_after_gc(BoolObjectClosure *is_alive_cl) {
 106   if (should_send_object_count_after_gc_event()) {
 107     ResourceMark rm;
 108 
 109     KlassInfoTable cit(HeapInspection::start_of_perm_gen());
 110     if (!cit.allocation_failed()) {
 111       ObjectCountEventSenderClosure event_sender(this);
 112       HeapInspection::instance_inspection(&cit, &event_sender, false, is_alive_cl);



 113     }
 114   }
 115 }
 116 
 117 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const PermGenSummary& perm_gen_summary) const {
 118   assert_set_gc_id();
 119 
 120   send_gc_heap_summary_event(when, heap_summary);
 121   send_perm_gen_summary_event(when, perm_gen_summary);
 122 }
 123 
 124 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
 125   assert_set_gc_id();
 126   assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
 127 
 128   GCTracer::report_gc_end_impl(timestamp, time_partitions);
 129   send_young_gc_event();
 130 
 131   _tenuring_threshold = UNSET_TENURING_THRESHOLD;
 132 }




  74   send_garbage_collection_event();
  75 }
  76 
  77 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) {
  78   assert_set_gc_id();
  79 
  80   report_gc_end_impl(timestamp, time_partitions);
  81 
  82   _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
  83 }
  84 
  85 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
  86   assert_set_gc_id();
  87 
  88   send_reference_stats_event(REF_SOFT, rps.soft_count());
  89   send_reference_stats_event(REF_WEAK, rps.weak_count());
  90   send_reference_stats_event(REF_FINAL, rps.final_count());
  91   send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
  92 }
  93 
  94 void ObjectCountEventSenderClosure::do_cinfo(KlassInfoEntry* entry) {
  95   if (should_send_event(entry)) {
  96     send_event(entry);
  97   }
  98 }
  99 
 100 void ObjectCountEventSenderClosure::send_event(KlassInfoEntry* entry) {
 101   _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(),
 102                                                entry->words() * BytesPerWord);
 103 }
 104 
 105 bool ObjectCountEventSenderClosure::should_send_event(KlassInfoEntry* entry) const {
 106   double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
 107   return percentage_of_heap > _size_threshold_percentage;
 108 }
 109 
 110 bool ObjectCountFilter::do_object_b(oop obj) {
 111   bool is_alive = _is_alive == NULL? true : _is_alive->do_object_b(obj);
 112   return is_alive && is_externally_visible_klass(obj->klass());
 113 }
 114 
 115 bool ObjectCountFilter::is_externally_visible_klass(klassOop k) const {
 116   // Do not expose internal implementation specific classes
 117   return (k->klass_part()->oop_is_instance() || k->klass_part()->oop_is_array()) &&
 118          k != Universe::systemObjArrayKlassObj();
 119 }
 120 
 121 void GCTracer::report_object_count_after_gc(BoolObjectClosure *is_alive_cl) {
 122   if (should_send_object_count_after_gc_event()) {
 123     ResourceMark rm;
 124 
 125     KlassInfoTable cit(HeapInspection::start_of_perm_gen());
 126     if (!cit.allocation_failed()) {
 127       ObjectCountFilter object_filter(is_alive_cl);
 128       HeapInspection::populate_table(&cit, false, &object_filter);
 129 
 130       ObjectCountEventSenderClosure event_sender(this, cit.size_of_instances_in_words());
 131       cit.iterate(&event_sender);
 132     }
 133   }
 134 }
 135 
 136 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const PermGenSummary& perm_gen_summary) const {
 137   assert_set_gc_id();
 138 
 139   send_gc_heap_summary_event(when, heap_summary);
 140   send_perm_gen_summary_event(when, perm_gen_summary);
 141 }
 142 
 143 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
 144   assert_set_gc_id();
 145   assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
 146 
 147   GCTracer::report_gc_end_impl(timestamp, time_partitions);
 148   send_young_gc_event();
 149 
 150   _tenuring_threshold = UNSET_TENURING_THRESHOLD;
 151 }