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/g1/g1YCTypes.hpp"
29 #include "gc/shared/gcTrace.hpp"
30 
31 class G1EvacuationInfo;
32 class G1HeapSummary;
33 class G1EvacSummary;
34 
35 class G1YoungGCInfo {
36   G1YCType _type;
37 public:
G1YoungGCInfo()38   G1YoungGCInfo() : _type(G1YCTypeEndSentinel) {}
set_type(G1YCType type)39   void set_type(G1YCType type) {
40     _type = type;
41   }
type() const42   G1YCType type() const { return _type; }
43 };
44 
45 class G1NewTracer : public YoungGCTracer {
46   G1YoungGCInfo _g1_young_gc_info;
47 
48 public:
G1NewTracer()49   G1NewTracer() : YoungGCTracer(G1New) {}
50 
51   void initialize();
52   void report_yc_type(G1YCType type);
53   void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
54   void report_evacuation_info(G1EvacuationInfo* info);
55   void report_evacuation_failed(EvacuationFailedInfo& ef_info);
56 
57   void report_evacuation_statistics(const G1EvacSummary& young_summary, const G1EvacSummary& old_summary) const;
58 
59   void report_basic_ihop_statistics(size_t threshold,
60                                     size_t target_occupancy,
61                                     size_t current_occupancy,
62                                     size_t last_allocation_size,
63                                     double last_allocation_duration,
64                                     double last_marking_length);
65   void report_adaptive_ihop_statistics(size_t threshold,
66                                        size_t internal_target_occupancy,
67                                        size_t current_occupancy,
68                                        size_t additional_buffer_size,
69                                        double predicted_allocation_rate,
70                                        double predicted_marking_length,
71                                        bool prediction_active);
72 private:
73   void send_g1_young_gc_event();
74   void send_evacuation_info_event(G1EvacuationInfo* info);
75   void send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const;
76 
77   void send_young_evacuation_statistics(const G1EvacSummary& summary) const;
78   void send_old_evacuation_statistics(const G1EvacSummary& summary) const;
79 
80   void send_basic_ihop_statistics(size_t threshold,
81                                   size_t target_occupancy,
82                                   size_t current_occupancy,
83                                   size_t last_allocation_size,
84                                   double last_allocation_duration,
85                                   double last_marking_length);
86   void send_adaptive_ihop_statistics(size_t threshold,
87                                      size_t internal_target_occupancy,
88                                      size_t current_occupancy,
89                                      size_t additional_buffer_size,
90                                      double predicted_allocation_rate,
91                                      double predicted_marking_length,
92                                      bool prediction_active);
93 };
94 
95 class G1OldTracer : public OldGCTracer {
96  protected:
97   void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp);
98  public:
G1OldTracer()99   G1OldTracer() : OldGCTracer(G1Old) {}
100   void set_gc_cause(GCCause::Cause cause);
101 };
102 
103 class G1FullGCTracer : public OldGCTracer {
104 public:
G1FullGCTracer()105   G1FullGCTracer() : OldGCTracer(G1Full) {}
106 };
107 
108 class G1MMUTracer : public AllStatic {
109   static void send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms);
110 
111 public:
112   static void report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec);
113 };
114 
115 #endif
116