1 /*
   2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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 #ifndef SHARE_GC_G1_G1TRACE_HPP
  26 #define SHARE_GC_G1_G1TRACE_HPP
  27 
  28 #include "gc/shared/gcTrace.hpp"
  29 #include "gc/g1/g1YCTypes.hpp"
  30 
  31 class G1EvacuationInfo;
  32 class G1HeapSummary;
  33 class G1EvacSummary;
  34 
  35 class G1YoungGCInfo {
  36   G1YCType _type;
  37 public:
  38   G1YoungGCInfo() : _type(G1YCTypeEndSentinel) {}
  39   void set_type(G1YCType type) {
  40     _type = type;
  41   }
  42   G1YCType type() const { return _type; }
  43 };
  44 
  45 class G1NewTracer : public YoungGCTracer {
  46   G1YoungGCInfo _g1_young_gc_info;
  47 
  48 public:
  49   G1NewTracer() : YoungGCTracer(G1New) {}
  50 
  51   void report_yc_type(G1YCType type);
  52   void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
  53   void report_evacuation_info(G1EvacuationInfo* info);
  54   void report_evacuation_failed(EvacuationFailedInfo& ef_info);
  55 
  56   void report_evacuation_statistics(const G1EvacSummary& young_summary, const G1EvacSummary& old_summary) const;
  57 
  58   void report_basic_ihop_statistics(size_t threshold,
  59                                     size_t target_occupancy,
  60                                     size_t current_occupancy,
  61                                     size_t last_allocation_size,
  62                                     double last_allocation_duration,
  63                                     double last_marking_length);
  64   void report_adaptive_ihop_statistics(size_t threshold,
  65                                        size_t internal_target_occupancy,
  66                                        size_t current_occupancy,
  67                                        size_t additional_buffer_size,
  68                                        double predicted_allocation_rate,
  69                                        double predicted_marking_length,
  70                                        bool prediction_active);
  71 private:
  72   void send_g1_young_gc_event();
  73   void send_evacuation_info_event(G1EvacuationInfo* info);
  74   void send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const;
  75 
  76   void send_young_evacuation_statistics(const G1EvacSummary& summary) const;
  77   void send_old_evacuation_statistics(const G1EvacSummary& summary) const;
  78 
  79   void send_basic_ihop_statistics(size_t threshold,
  80                                   size_t target_occupancy,
  81                                   size_t current_occupancy,
  82                                   size_t last_allocation_size,
  83                                   double last_allocation_duration,
  84                                   double last_marking_length);
  85   void send_adaptive_ihop_statistics(size_t threshold,
  86                                      size_t internal_target_occupancy,
  87                                      size_t current_occupancy,
  88                                      size_t additional_buffer_size,
  89                                      double predicted_allocation_rate,
  90                                      double predicted_marking_length,
  91                                      bool prediction_active);
  92 };
  93 
  94 class G1OldTracer : public OldGCTracer {
  95  protected:
  96   void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp);
  97  public:
  98   G1OldTracer() : OldGCTracer(G1Old) {}
  99   void set_gc_cause(GCCause::Cause cause);
 100 };
 101 
 102 class G1FullGCTracer : public OldGCTracer {
 103 public:
 104   G1FullGCTracer() : OldGCTracer(G1Full) {}
 105 };
 106 
 107 class G1MMUTracer : public AllStatic {
 108   static void send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms);
 109 
 110 public:
 111   static void report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec);
 112 };
 113 
 114 #endif