author | mgronlun |
Sat, 14 Sep 2019 13:03:44 +0200 | |
branch | JEP-349-branch |
changeset 58154 | 060d9d139109 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49392
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
1374 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49392
diff
changeset
|
25 |
#ifndef SHARE_GC_G1_G1MMUTRACKER_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49392
diff
changeset
|
26 |
#define SHARE_GC_G1_G1MMUTRACKER_HPP |
7397 | 27 |
|
31619 | 28 |
#include "gc/shared/gcId.hpp" |
7397 | 29 |
#include "memory/allocation.hpp" |
30 |
#include "utilities/debug.hpp" |
|
31 |
||
33598
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
32 |
// Two major user controls over G1 behavior are setting a pause time goal (MaxGCPauseMillis), |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
33 |
// over a time slice (GCPauseIntervalMillis). This defines the Minimum Mutator |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
34 |
// Utilisation (MMU) goal. |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
35 |
// |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
36 |
// * Definitions * |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
37 |
// Mutator Utilisation: |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
38 |
// - for a given time slice duration "ts", |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
39 |
// - mutator utilisation is the following fraction: |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
40 |
// non_gc_time / ts |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
41 |
// |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
42 |
// Minimum Mutator Utilisation (MMU): |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
43 |
// - the worst mutator utilisation across all time slices. |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
44 |
// |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
45 |
// G1MMUTracker keeps track of the GC work and decides when it is OK to do GC work |
1374 | 46 |
// and for how long so that the MMU invariants are maintained. |
33598
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
47 |
// |
e230df0ac751
8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents:
33130
diff
changeset
|
48 |
// ***** ALL TIMES ARE IN SECS!!!!!!! ***** |
1374 | 49 |
// this is the "interface" |
13195 | 50 |
class G1MMUTracker: public CHeapObj<mtGC> { |
1374 | 51 |
protected: |
52 |
double _time_slice; |
|
53 |
double _max_gc_time; // this is per time slice |
|
54 |
||
55 |
public: |
|
56 |
G1MMUTracker(double time_slice, double max_gc_time); |
|
57 |
||
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
31619
diff
changeset
|
58 |
virtual void add_pause(double start, double end) = 0; |
1374 | 59 |
virtual double when_sec(double current_time, double pause_time) = 0; |
60 |
||
33130
a776072941e8
8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents:
33107
diff
changeset
|
61 |
double max_gc_time() const { |
3691 | 62 |
return _max_gc_time; |
1374 | 63 |
} |
64 |
||
65 |
inline bool now_max_gc(double current_time) { |
|
66 |
return when_sec(current_time, max_gc_time()) < 0.00001; |
|
67 |
} |
|
68 |
||
69 |
inline double when_max_gc_sec(double current_time) { |
|
70 |
return when_sec(current_time, max_gc_time()); |
|
71 |
} |
|
72 |
||
73 |
inline jlong when_max_gc_ms(double current_time) { |
|
74 |
double when = when_max_gc_sec(current_time); |
|
75 |
return (jlong) (when * 1000.0); |
|
76 |
} |
|
77 |
||
78 |
inline jlong when_ms(double current_time, double pause_time) { |
|
79 |
double when = when_sec(current_time, pause_time); |
|
80 |
return (jlong) (when * 1000.0); |
|
81 |
} |
|
82 |
}; |
|
83 |
||
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47817
diff
changeset
|
84 |
class G1MMUTrackerQueueElem { |
1374 | 85 |
private: |
86 |
double _start_time; |
|
87 |
double _end_time; |
|
88 |
||
89 |
public: |
|
90 |
inline double start_time() { return _start_time; } |
|
91 |
inline double end_time() { return _end_time; } |
|
92 |
inline double duration() { return _end_time - _start_time; } |
|
93 |
||
94 |
G1MMUTrackerQueueElem() { |
|
95 |
_start_time = 0.0; |
|
96 |
_end_time = 0.0; |
|
97 |
} |
|
98 |
||
99 |
G1MMUTrackerQueueElem(double start_time, double end_time) { |
|
100 |
_start_time = start_time; |
|
101 |
_end_time = end_time; |
|
102 |
} |
|
103 |
}; |
|
104 |
||
105 |
// this is an implementation of the MMUTracker using a (fixed-size) queue |
|
106 |
// that keeps track of all the recent pause times |
|
107 |
class G1MMUTrackerQueue: public G1MMUTracker { |
|
108 |
private: |
|
109 |
enum PrivateConstants { |
|
110 |
QueueLength = 64 |
|
111 |
}; |
|
112 |
||
113 |
// The array keeps track of all the pauses that fall within a time |
|
114 |
// slice (the last time slice during which pauses took place). |
|
115 |
// The data structure implemented is a circular queue. |
|
116 |
// Head "points" to the most recent addition, tail to the oldest one. |
|
117 |
// The array is of fixed size and I don't think we'll need more than |
|
22551 | 118 |
// two or three entries with the current behavior of G1 pauses. |
1374 | 119 |
// If the array is full, an easy fix is to look for the pauses with |
4458
075a9ef4e467
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
3691
diff
changeset
|
120 |
// the shortest gap between them and consolidate them. |
075a9ef4e467
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
3691
diff
changeset
|
121 |
// For now, we have taken the expedient alternative of forgetting |
5033 | 122 |
// the oldest entry in the event that +G1UseFixedWindowMMUTracker, thus |
4458
075a9ef4e467
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
3691
diff
changeset
|
123 |
// potentially violating MMU specs for some time thereafter. |
1374 | 124 |
|
125 |
G1MMUTrackerQueueElem _array[QueueLength]; |
|
126 |
int _head_index; |
|
127 |
int _tail_index; |
|
128 |
int _no_entries; |
|
129 |
||
130 |
inline int trim_index(int index) { |
|
131 |
return (index + QueueLength) % QueueLength; |
|
132 |
} |
|
133 |
||
134 |
void remove_expired_entries(double current_time); |
|
135 |
double calculate_gc_time(double current_time); |
|
136 |
||
137 |
public: |
|
138 |
G1MMUTrackerQueue(double time_slice, double max_gc_time); |
|
139 |
||
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
31619
diff
changeset
|
140 |
virtual void add_pause(double start, double end); |
1374 | 141 |
|
142 |
virtual double when_sec(double current_time, double pause_time); |
|
143 |
}; |
|
7397 | 144 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49392
diff
changeset
|
145 |
#endif // SHARE_GC_G1_G1MMUTRACKER_HPP |