Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/g1/g1Analytics.hpp
40957 views
1
/*
2
* Copyright (c) 2016, 2020, 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_G1ANALYTICS_HPP
26
#define SHARE_GC_G1_G1ANALYTICS_HPP
27
28
#include "memory/allocation.hpp"
29
#include "utilities/globalDefinitions.hpp"
30
31
class TruncatedSeq;
32
class G1Predictions;
33
34
class G1Analytics: public CHeapObj<mtGC> {
35
const static int TruncatedSeqLength = 10;
36
const static int NumPrevPausesForHeuristics = 10;
37
const G1Predictions* _predictor;
38
39
// These exclude marking times.
40
TruncatedSeq* _recent_gc_times_ms;
41
42
TruncatedSeq* _concurrent_mark_remark_times_ms;
43
TruncatedSeq* _concurrent_mark_cleanup_times_ms;
44
45
TruncatedSeq* _alloc_rate_ms_seq;
46
double _prev_collection_pause_end_ms;
47
48
TruncatedSeq* _rs_length_diff_seq;
49
TruncatedSeq* _concurrent_refine_rate_ms_seq;
50
TruncatedSeq* _dirtied_cards_rate_ms_seq;
51
// The ratio between the number of merged cards and actually scanned cards, for
52
// young-only and mixed gcs.
53
TruncatedSeq* _young_card_merge_to_scan_ratio_seq;
54
TruncatedSeq* _mixed_card_merge_to_scan_ratio_seq;
55
56
// The cost to scan a card during young-only and mixed gcs in ms.
57
TruncatedSeq* _young_cost_per_card_scan_ms_seq;
58
TruncatedSeq* _mixed_cost_per_card_scan_ms_seq;
59
60
// The cost to merge a card during young-only and mixed gcs in ms.
61
TruncatedSeq* _young_cost_per_card_merge_ms_seq;
62
TruncatedSeq* _mixed_cost_per_card_merge_ms_seq;
63
64
// The cost to copy a byte in ms.
65
TruncatedSeq* _copy_cost_per_byte_ms_seq;
66
TruncatedSeq* _constant_other_time_ms_seq;
67
TruncatedSeq* _young_other_cost_per_region_ms_seq;
68
TruncatedSeq* _non_young_other_cost_per_region_ms_seq;
69
70
TruncatedSeq* _pending_cards_seq;
71
TruncatedSeq* _rs_length_seq;
72
73
TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
74
75
// Statistics kept per GC stoppage, pause or full.
76
TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
77
78
// Cached values for long and short term pause time ratios. See
79
// compute_pause_time_ratios() for how they are computed.
80
double _long_term_pause_time_ratio;
81
double _short_term_pause_time_ratio;
82
83
// Returns whether the sequence have enough samples to get a "good" prediction.
84
// The constant used is random but "small".
85
bool enough_samples_available(TruncatedSeq const* seq) const;
86
87
double predict_in_unit_interval(TruncatedSeq const* seq) const;
88
size_t predict_size(TruncatedSeq const* seq) const;
89
double predict_zero_bounded(TruncatedSeq const* seq) const;
90
91
double oldest_known_gc_end_time_sec() const;
92
double most_recent_gc_end_time_sec() const;
93
94
public:
95
G1Analytics(const G1Predictions* predictor);
96
97
double prev_collection_pause_end_ms() const {
98
return _prev_collection_pause_end_ms;
99
}
100
101
double long_term_pause_time_ratio() const {
102
return _long_term_pause_time_ratio;
103
}
104
105
double short_term_pause_time_ratio() const {
106
return _short_term_pause_time_ratio;
107
}
108
109
uint number_of_recorded_pause_times() const {
110
return NumPrevPausesForHeuristics;
111
}
112
113
void append_prev_collection_pause_end_ms(double ms) {
114
_prev_collection_pause_end_ms += ms;
115
}
116
117
void set_prev_collection_pause_end_ms(double ms) {
118
_prev_collection_pause_end_ms = ms;
119
}
120
121
void report_concurrent_mark_remark_times_ms(double ms);
122
void report_concurrent_mark_cleanup_times_ms(double ms);
123
void report_alloc_rate_ms(double alloc_rate);
124
void report_concurrent_refine_rate_ms(double cards_per_ms);
125
void report_dirtied_cards_rate_ms(double cards_per_ms);
126
void report_cost_per_card_scan_ms(double cost_per_remset_card_ms, bool for_young_gc);
127
void report_cost_per_card_merge_ms(double cost_per_card_ms, bool for_young_gc);
128
void report_card_merge_to_scan_ratio(double cards_per_entry_ratio, bool for_young_gc);
129
void report_rs_length_diff(double rs_length_diff);
130
void report_cost_per_byte_ms(double cost_per_byte_ms, bool mark_or_rebuild_in_progress);
131
void report_young_other_cost_per_region_ms(double other_cost_per_region_ms);
132
void report_non_young_other_cost_per_region_ms(double other_cost_per_region_ms);
133
void report_constant_other_time_ms(double constant_other_time_ms);
134
void report_pending_cards(double pending_cards);
135
void report_rs_length(double rs_length);
136
137
double predict_alloc_rate_ms() const;
138
int num_alloc_rate_ms() const;
139
140
double predict_concurrent_refine_rate_ms() const;
141
double predict_dirtied_cards_rate_ms() const;
142
double predict_young_card_merge_to_scan_ratio() const;
143
144
double predict_mixed_card_merge_to_scan_ratio() const;
145
146
size_t predict_scan_card_num(size_t rs_length, bool for_young_gc) const;
147
148
double predict_card_merge_time_ms(size_t card_num, bool for_young_gc) const;
149
double predict_card_scan_time_ms(size_t card_num, bool for_young_gc) const;
150
151
double predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const;
152
153
double predict_object_copy_time_ms(size_t bytes_to_copy, bool during_concurrent_mark) const;
154
155
double predict_constant_other_time_ms() const;
156
157
double predict_young_other_time_ms(size_t young_num) const;
158
159
double predict_non_young_other_time_ms(size_t non_young_num) const;
160
161
double predict_remark_time_ms() const;
162
163
double predict_cleanup_time_ms() const;
164
165
size_t predict_rs_length() const;
166
size_t predict_pending_cards() const;
167
168
// Add a new GC of the given duration and end time to the record.
169
void update_recent_gc_times(double end_time_sec, double elapsed_ms);
170
void compute_pause_time_ratios(double end_time_sec, double pause_time_ms);
171
};
172
173
#endif // SHARE_GC_G1_G1ANALYTICS_HPP
174
175