hotspot/src/share/vm/gc/shared/gcTraceSend.cpp
changeset 33107 77bf0d2069a3
parent 32380 1dcdb686f0cb
child 34300 6075c1e0e913
equal deleted inserted replaced
33106:20c533b9e167 33107:77bf0d2069a3
    42 typedef uintptr_t TraceAddress;
    42 typedef uintptr_t TraceAddress;
    43 
    43 
    44 void GCTracer::send_garbage_collection_event() const {
    44 void GCTracer::send_garbage_collection_event() const {
    45   EventGCGarbageCollection event(UNTIMED);
    45   EventGCGarbageCollection event(UNTIMED);
    46   if (event.should_commit()) {
    46   if (event.should_commit()) {
    47     event.set_gcId(_shared_gc_info.gc_id().id());
    47     event.set_gcId(GCId::current());
    48     event.set_name(_shared_gc_info.name());
    48     event.set_name(_shared_gc_info.name());
    49     event.set_cause((u2) _shared_gc_info.cause());
    49     event.set_cause((u2) _shared_gc_info.cause());
    50     event.set_sumOfPauses(_shared_gc_info.sum_of_pauses());
    50     event.set_sumOfPauses(_shared_gc_info.sum_of_pauses());
    51     event.set_longestPause(_shared_gc_info.longest_pause());
    51     event.set_longestPause(_shared_gc_info.longest_pause());
    52     event.set_starttime(_shared_gc_info.start_timestamp());
    52     event.set_starttime(_shared_gc_info.start_timestamp());
    56 }
    56 }
    57 
    57 
    58 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
    58 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
    59   EventGCReferenceStatistics e;
    59   EventGCReferenceStatistics e;
    60   if (e.should_commit()) {
    60   if (e.should_commit()) {
    61       e.set_gcId(_shared_gc_info.gc_id().id());
    61       e.set_gcId(GCId::current());
    62       e.set_type((u1)type);
    62       e.set_type((u1)type);
    63       e.set_count(count);
    63       e.set_count(count);
    64       e.commit();
    64       e.commit();
    65   }
    65   }
    66 }
    66 }
    67 
    67 
    68 void GCTracer::send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspace::MetadataType mdtype,
    68 void GCTracer::send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspace::MetadataType mdtype,
    69                                                       const MetaspaceChunkFreeListSummary& summary) const {
    69                                                       const MetaspaceChunkFreeListSummary& summary) const {
    70   EventMetaspaceChunkFreeListSummary e;
    70   EventMetaspaceChunkFreeListSummary e;
    71   if (e.should_commit()) {
    71   if (e.should_commit()) {
    72     e.set_gcId(_shared_gc_info.gc_id().id());
    72     e.set_gcId(GCId::current());
    73     e.set_when(when);
    73     e.set_when(when);
    74     e.set_metadataType(mdtype);
    74     e.set_metadataType(mdtype);
    75 
    75 
    76     e.set_specializedChunks(summary.num_specialized_chunks());
    76     e.set_specializedChunks(summary.num_specialized_chunks());
    77     e.set_specializedChunksTotalSize(summary.specialized_chunks_size_in_bytes());
    77     e.set_specializedChunksTotalSize(summary.specialized_chunks_size_in_bytes());
    90 }
    90 }
    91 
    91 
    92 void ParallelOldTracer::send_parallel_old_event() const {
    92 void ParallelOldTracer::send_parallel_old_event() const {
    93   EventGCParallelOld e(UNTIMED);
    93   EventGCParallelOld e(UNTIMED);
    94   if (e.should_commit()) {
    94   if (e.should_commit()) {
    95     e.set_gcId(_shared_gc_info.gc_id().id());
    95     e.set_gcId(GCId::current());
    96     e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
    96     e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
    97     e.set_starttime(_shared_gc_info.start_timestamp());
    97     e.set_starttime(_shared_gc_info.start_timestamp());
    98     e.set_endtime(_shared_gc_info.end_timestamp());
    98     e.set_endtime(_shared_gc_info.end_timestamp());
    99     e.commit();
    99     e.commit();
   100   }
   100   }
   101 }
   101 }
   102 
   102 
   103 void YoungGCTracer::send_young_gc_event() const {
   103 void YoungGCTracer::send_young_gc_event() const {
   104   EventGCYoungGarbageCollection e(UNTIMED);
   104   EventGCYoungGarbageCollection e(UNTIMED);
   105   if (e.should_commit()) {
   105   if (e.should_commit()) {
   106     e.set_gcId(_shared_gc_info.gc_id().id());
   106     e.set_gcId(GCId::current());
   107     e.set_tenuringThreshold(_tenuring_threshold);
   107     e.set_tenuringThreshold(_tenuring_threshold);
   108     e.set_starttime(_shared_gc_info.start_timestamp());
   108     e.set_starttime(_shared_gc_info.start_timestamp());
   109     e.set_endtime(_shared_gc_info.end_timestamp());
   109     e.set_endtime(_shared_gc_info.end_timestamp());
   110     e.commit();
   110     e.commit();
   111   }
   111   }
   123                                                      uint age, bool tenured,
   123                                                      uint age, bool tenured,
   124                                                      size_t plab_size) const {
   124                                                      size_t plab_size) const {
   125 
   125 
   126   EventPromoteObjectInNewPLAB event;
   126   EventPromoteObjectInNewPLAB event;
   127   if (event.should_commit()) {
   127   if (event.should_commit()) {
   128     event.set_gcId(_shared_gc_info.gc_id().id());
   128     event.set_gcId(GCId::current());
   129     event.set_class(klass);
   129     event.set_class(klass);
   130     event.set_objectSize(obj_size);
   130     event.set_objectSize(obj_size);
   131     event.set_tenured(tenured);
   131     event.set_tenured(tenured);
   132     event.set_tenuringAge(age);
   132     event.set_tenuringAge(age);
   133     event.set_plabSize(plab_size);
   133     event.set_plabSize(plab_size);
   138 void YoungGCTracer::send_promotion_outside_plab_event(Klass* klass, size_t obj_size,
   138 void YoungGCTracer::send_promotion_outside_plab_event(Klass* klass, size_t obj_size,
   139                                                       uint age, bool tenured) const {
   139                                                       uint age, bool tenured) const {
   140 
   140 
   141   EventPromoteObjectOutsidePLAB event;
   141   EventPromoteObjectOutsidePLAB event;
   142   if (event.should_commit()) {
   142   if (event.should_commit()) {
   143     event.set_gcId(_shared_gc_info.gc_id().id());
   143     event.set_gcId(GCId::current());
   144     event.set_class(klass);
   144     event.set_class(klass);
   145     event.set_objectSize(obj_size);
   145     event.set_objectSize(obj_size);
   146     event.set_tenured(tenured);
   146     event.set_tenured(tenured);
   147     event.set_tenuringAge(age);
   147     event.set_tenuringAge(age);
   148     event.commit();
   148     event.commit();
   150 }
   150 }
   151 
   151 
   152 void OldGCTracer::send_old_gc_event() const {
   152 void OldGCTracer::send_old_gc_event() const {
   153   EventGCOldGarbageCollection e(UNTIMED);
   153   EventGCOldGarbageCollection e(UNTIMED);
   154   if (e.should_commit()) {
   154   if (e.should_commit()) {
   155     e.set_gcId(_shared_gc_info.gc_id().id());
   155     e.set_gcId(GCId::current());
   156     e.set_starttime(_shared_gc_info.start_timestamp());
   156     e.set_starttime(_shared_gc_info.start_timestamp());
   157     e.set_endtime(_shared_gc_info.end_timestamp());
   157     e.set_endtime(_shared_gc_info.end_timestamp());
   158     e.commit();
   158     e.commit();
   159   }
   159   }
   160 }
   160 }
   169 }
   169 }
   170 
   170 
   171 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
   171 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
   172   EventPromotionFailed e;
   172   EventPromotionFailed e;
   173   if (e.should_commit()) {
   173   if (e.should_commit()) {
   174     e.set_gcId(_shared_gc_info.gc_id().id());
   174     e.set_gcId(GCId::current());
   175     e.set_data(to_trace_struct(pf_info));
   175     e.set_data(to_trace_struct(pf_info));
   176     e.set_thread(pf_info.thread()->thread_id());
   176     e.set_thread(pf_info.thread()->thread_id());
   177     e.commit();
   177     e.commit();
   178   }
   178   }
   179 }
   179 }
   180 
   180 
   181 // Common to CMS and G1
   181 // Common to CMS and G1
   182 void OldGCTracer::send_concurrent_mode_failure_event() {
   182 void OldGCTracer::send_concurrent_mode_failure_event() {
   183   EventConcurrentModeFailure e;
   183   EventConcurrentModeFailure e;
   184   if (e.should_commit()) {
   184   if (e.should_commit()) {
   185     e.set_gcId(_shared_gc_info.gc_id().id());
   185     e.set_gcId(GCId::current());
   186     e.commit();
   186     e.commit();
   187   }
   187   }
   188 }
   188 }
   189 
   189 
   190 #if INCLUDE_ALL_GCS
   190 #if INCLUDE_ALL_GCS
   191 void G1NewTracer::send_g1_young_gc_event() {
   191 void G1NewTracer::send_g1_young_gc_event() {
   192   EventGCG1GarbageCollection e(UNTIMED);
   192   EventGCG1GarbageCollection e(UNTIMED);
   193   if (e.should_commit()) {
   193   if (e.should_commit()) {
   194     e.set_gcId(_shared_gc_info.gc_id().id());
   194     e.set_gcId(GCId::current());
   195     e.set_type(_g1_young_gc_info.type());
   195     e.set_type(_g1_young_gc_info.type());
   196     e.set_starttime(_shared_gc_info.start_timestamp());
   196     e.set_starttime(_shared_gc_info.start_timestamp());
   197     e.set_endtime(_shared_gc_info.end_timestamp());
   197     e.set_endtime(_shared_gc_info.end_timestamp());
   198     e.commit();
   198     e.commit();
   199   }
   199   }
   200 }
   200 }
   201 
   201 
   202 void G1MMUTracer::send_g1_mmu_event(const GCId& gcId, double timeSlice, double gcTime, double maxTime) {
   202 void G1MMUTracer::send_g1_mmu_event(double timeSlice, double gcTime, double maxTime) {
   203   EventGCG1MMU e;
   203   EventGCG1MMU e;
   204   if (e.should_commit()) {
   204   if (e.should_commit()) {
   205     e.set_gcId(gcId.id());
   205     e.set_gcId(GCId::current());
   206     e.set_timeSlice(timeSlice);
   206     e.set_timeSlice(timeSlice);
   207     e.set_gcTime(gcTime);
   207     e.set_gcTime(gcTime);
   208     e.set_maxGcTime(maxTime);
   208     e.set_maxGcTime(maxTime);
   209     e.commit();
   209     e.commit();
   210   }
   210   }
   211 }
   211 }
   212 
   212 
   213 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
   213 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
   214   EventEvacuationInfo e;
   214   EventEvacuationInfo e;
   215   if (e.should_commit()) {
   215   if (e.should_commit()) {
   216     e.set_gcId(_shared_gc_info.gc_id().id());
   216     e.set_gcId(GCId::current());
   217     e.set_cSetRegions(info->collectionset_regions());
   217     e.set_cSetRegions(info->collectionset_regions());
   218     e.set_cSetUsedBefore(info->collectionset_used_before());
   218     e.set_cSetUsedBefore(info->collectionset_used_before());
   219     e.set_cSetUsedAfter(info->collectionset_used_after());
   219     e.set_cSetUsedAfter(info->collectionset_used_after());
   220     e.set_allocationRegions(info->allocation_regions());
   220     e.set_allocationRegions(info->allocation_regions());
   221     e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
   221     e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
   227 }
   227 }
   228 
   228 
   229 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
   229 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
   230   EventEvacuationFailed e;
   230   EventEvacuationFailed e;
   231   if (e.should_commit()) {
   231   if (e.should_commit()) {
   232     e.set_gcId(_shared_gc_info.gc_id().id());
   232     e.set_gcId(GCId::current());
   233     e.set_data(to_trace_struct(ef_info));
   233     e.set_data(to_trace_struct(ef_info));
   234     e.commit();
   234     e.commit();
   235   }
   235   }
   236 }
   236 }
   237 
   237 
   251 }
   251 }
   252 
   252 
   253 void G1NewTracer::send_young_evacuation_statistics(const G1EvacSummary& summary) const {
   253 void G1NewTracer::send_young_evacuation_statistics(const G1EvacSummary& summary) const {
   254   EventGCG1EvacuationYoungStatistics surv_evt;
   254   EventGCG1EvacuationYoungStatistics surv_evt;
   255   if (surv_evt.should_commit()) {
   255   if (surv_evt.should_commit()) {
   256     surv_evt.set_stats(create_g1_evacstats(_shared_gc_info.gc_id().id(), summary));
   256     surv_evt.set_stats(create_g1_evacstats(GCId::current(), summary));
   257     surv_evt.commit();
   257     surv_evt.commit();
   258   }
   258   }
   259 }
   259 }
   260 
   260 
   261 void G1NewTracer::send_old_evacuation_statistics(const G1EvacSummary& summary) const {
   261 void G1NewTracer::send_old_evacuation_statistics(const G1EvacSummary& summary) const {
   262   EventGCG1EvacuationOldStatistics old_evt;
   262   EventGCG1EvacuationOldStatistics old_evt;
   263   if (old_evt.should_commit()) {
   263   if (old_evt.should_commit()) {
   264     old_evt.set_stats(create_g1_evacstats(_shared_gc_info.gc_id().id(), summary));
   264     old_evt.set_stats(create_g1_evacstats(GCId::current(), summary));
   265     old_evt.commit();
   265     old_evt.commit();
   266   }
   266   }
   267 }
   267 }
   268 #endif
   268 #endif
   269 
   269 
   285   space.set_size(summary.size());
   285   space.set_size(summary.size());
   286   return space;
   286   return space;
   287 }
   287 }
   288 
   288 
   289 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
   289 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
   290   GCId _gc_id;
       
   291   GCWhen::Type _when;
   290   GCWhen::Type _when;
   292  public:
   291  public:
   293   GCHeapSummaryEventSender(GCId gc_id, GCWhen::Type when) : _gc_id(gc_id), _when(when) {}
   292   GCHeapSummaryEventSender(GCWhen::Type when) : _when(when) {}
   294 
   293 
   295   void visit(const GCHeapSummary* heap_summary) const {
   294   void visit(const GCHeapSummary* heap_summary) const {
   296     const VirtualSpaceSummary& heap_space = heap_summary->heap();
   295     const VirtualSpaceSummary& heap_space = heap_summary->heap();
   297 
   296 
   298     EventGCHeapSummary e;
   297     EventGCHeapSummary e;
   299     if (e.should_commit()) {
   298     if (e.should_commit()) {
   300       e.set_gcId(_gc_id.id());
   299       e.set_gcId(GCId::current());
   301       e.set_when((u1)_when);
   300       e.set_when((u1)_when);
   302       e.set_heapSpace(to_trace_struct(heap_space));
   301       e.set_heapSpace(to_trace_struct(heap_space));
   303       e.set_heapUsed(heap_summary->used());
   302       e.set_heapUsed(heap_summary->used());
   304       e.commit();
   303       e.commit();
   305     }
   304     }
   308   void visit(const G1HeapSummary* g1_heap_summary) const {
   307   void visit(const G1HeapSummary* g1_heap_summary) const {
   309     visit((GCHeapSummary*)g1_heap_summary);
   308     visit((GCHeapSummary*)g1_heap_summary);
   310 
   309 
   311     EventG1HeapSummary e;
   310     EventG1HeapSummary e;
   312     if (e.should_commit()) {
   311     if (e.should_commit()) {
   313       e.set_gcId(_gc_id.id());
   312       e.set_gcId(GCId::current());
   314       e.set_when((u1)_when);
   313       e.set_when((u1)_when);
   315       e.set_edenUsedSize(g1_heap_summary->edenUsed());
   314       e.set_edenUsedSize(g1_heap_summary->edenUsed());
   316       e.set_edenTotalSize(g1_heap_summary->edenCapacity());
   315       e.set_edenTotalSize(g1_heap_summary->edenCapacity());
   317       e.set_survivorUsedSize(g1_heap_summary->survivorUsed());
   316       e.set_survivorUsedSize(g1_heap_summary->survivorUsed());
   318       e.commit();
   317       e.commit();
   329     const SpaceSummary& from_space = ps_heap_summary->from();
   328     const SpaceSummary& from_space = ps_heap_summary->from();
   330     const SpaceSummary& to_space = ps_heap_summary->to();
   329     const SpaceSummary& to_space = ps_heap_summary->to();
   331 
   330 
   332     EventPSHeapSummary e;
   331     EventPSHeapSummary e;
   333     if (e.should_commit()) {
   332     if (e.should_commit()) {
   334       e.set_gcId(_gc_id.id());
   333       e.set_gcId(GCId::current());
   335       e.set_when((u1)_when);
   334       e.set_when((u1)_when);
   336 
   335 
   337       e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
   336       e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
   338       e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
   337       e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
   339       e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
   338       e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
   344     }
   343     }
   345   }
   344   }
   346 };
   345 };
   347 
   346 
   348 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
   347 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
   349   GCHeapSummaryEventSender visitor(_shared_gc_info.gc_id(), when);
   348   GCHeapSummaryEventSender visitor(when);
   350   heap_summary.accept(&visitor);
   349   heap_summary.accept(&visitor);
   351 }
   350 }
   352 
   351 
   353 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
   352 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
   354   TraceStructMetaspaceSizes meta_sizes;
   353   TraceStructMetaspaceSizes meta_sizes;
   361 }
   360 }
   362 
   361 
   363 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
   362 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
   364   EventMetaspaceSummary e;
   363   EventMetaspaceSummary e;
   365   if (e.should_commit()) {
   364   if (e.should_commit()) {
   366     e.set_gcId(_shared_gc_info.gc_id().id());
   365     e.set_gcId(GCId::current());
   367     e.set_when((u1) when);
   366     e.set_when((u1) when);
   368     e.set_gcThreshold(meta_space_summary.capacity_until_GC());
   367     e.set_gcThreshold(meta_space_summary.capacity_until_GC());
   369     e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
   368     e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
   370     e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
   369     e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
   371     e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
   370     e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
   372     e.commit();
   371     e.commit();
   373   }
   372   }
   374 }
   373 }
   375 
   374 
   376 class PhaseSender : public PhaseVisitor {
   375 class PhaseSender : public PhaseVisitor {
   377   GCId _gc_id;
       
   378  public:
   376  public:
   379   PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
       
   380 
       
   381   template<typename T>
   377   template<typename T>
   382   void send_phase(PausePhase* pause) {
   378   void send_phase(PausePhase* pause) {
   383     T event(UNTIMED);
   379     T event(UNTIMED);
   384     if (event.should_commit()) {
   380     if (event.should_commit()) {
   385       event.set_gcId(_gc_id.id());
   381       event.set_gcId(GCId::current());
   386       event.set_name(pause->name());
   382       event.set_name(pause->name());
   387       event.set_starttime(pause->start());
   383       event.set_starttime(pause->start());
   388       event.set_endtime(pause->end());
   384       event.set_endtime(pause->end());
   389       event.commit();
   385       event.commit();
   390     }
   386     }
   404     }
   400     }
   405   }
   401   }
   406 };
   402 };
   407 
   403 
   408 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
   404 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
   409   PhaseSender phase_reporter(_shared_gc_info.gc_id());
   405   PhaseSender phase_reporter;
   410 
   406 
   411   TimePartitionPhasesIterator iter(time_partitions);
   407   TimePartitionPhasesIterator iter(time_partitions);
   412   while (iter.has_next()) {
   408   while (iter.has_next()) {
   413     GCPhase* phase = iter.next();
   409     GCPhase* phase = iter.next();
   414     phase->accept(&phase_reporter);
   410     phase->accept(&phase_reporter);