11/*
2- * Copyright (c) 2001, 2019 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2001, 2020 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2929#include " memory/allocation.hpp"
3030#include " utilities/debug.hpp"
3131
32- // Two major user controls over G1 behavior are setting a pause time goal (MaxGCPauseMillis),
33- // over a time slice (GCPauseIntervalMillis). This defines the Minimum Mutator
34- // Utilisation (MMU) goal.
35- //
36- // * Definitions *
37- // Mutator Utilisation:
38- // - for a given time slice duration "ts",
39- // - mutator utilisation is the following fraction:
40- // non_gc_time / ts
41- //
42- // Minimum Mutator Utilisation (MMU):
43- // - the worst mutator utilisation across all time slices.
44- //
45- // G1MMUTracker keeps track of the GC work and decides when it is OK to do GC work
46- // and for how long so that the MMU invariants are maintained.
47- //
48- // ***** ALL TIMES ARE IN SECS!!!!!!! *****
49- // this is the "interface"
50- class G1MMUTracker : public CHeapObj <mtGC> {
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-
58- virtual void add_pause (double start, double end) = 0;
59- virtual double when_sec (double current_time, double pause_time) = 0;
60-
61- double max_gc_time () const {
62- return _max_gc_time;
63- }
64-
65- inline double when_max_gc_sec (double current_time) {
66- return when_sec (current_time, max_gc_time ());
67- }
68- };
69-
70- class G1MMUTrackerQueueElem {
32+ class G1MMUTrackerElem {
7133private:
7234 double _start_time;
7335 double _end_time;
@@ -77,25 +39,45 @@ class G1MMUTrackerQueueElem {
7739 inline double end_time () { return _end_time; }
7840 inline double duration () { return _end_time - _start_time; }
7941
80- G1MMUTrackerQueueElem () {
42+ G1MMUTrackerElem () {
8143 _start_time = 0.0 ;
8244 _end_time = 0.0 ;
8345 }
8446
85- G1MMUTrackerQueueElem (double start_time, double end_time) {
47+ G1MMUTrackerElem (double start_time, double end_time) {
8648 _start_time = start_time;
8749 _end_time = end_time;
8850 }
8951};
9052
91- // this is an implementation of the MMUTracker using a (fixed-size) queue
92- // that keeps track of all the recent pause times
93- class G1MMUTrackerQueue : public G1MMUTracker {
53+
54+ // Two major user controls over G1 behavior are setting a pause
55+ // time goal (MaxGCPauseMillis), over a time slice (GCPauseIntervalMillis).
56+ // This defines the Minimum Mutator Utilisation (MMU) goal.
57+ //
58+ // * Definitions *
59+ // Mutator Utilisation:
60+ // - for a given time slice duration "ts",
61+ // - mutator utilisation is the following fraction:
62+ // non_gc_time / ts
63+ //
64+ // Minimum Mutator Utilisation (MMU):
65+ // - the worst mutator utilisation across all time slices.
66+ //
67+ // The G1MMUTracker uses a fixed-size queue to keep track of all
68+ // recent pause times. The pause time data is used to avoid
69+ // breaking the MMU.
70+ //
71+ // ***** ALL TIMES ARE IN SECS!!!!!!! *****
72+ class G1MMUTracker : public CHeapObj <mtGC> {
9473private:
9574 enum PrivateConstants {
9675 QueueLength = 64
9776 };
9877
78+ double _time_slice;
79+ double _max_gc_time; // this is per time slice
80+
9981 // The array keeps track of all the pauses that fall within a time
10082 // slice (the last time slice during which pauses took place).
10183 // The data structure implemented is a circular queue.
@@ -105,13 +87,13 @@ class G1MMUTrackerQueue: public G1MMUTracker {
10587 // If the array is full, an easy fix is to look for the pauses with
10688 // the shortest gap between them and consolidate them.
10789 // For now, we have taken the expedient alternative of forgetting
108- // the oldest entry in the event that +G1UseFixedWindowMMUTracker, thus
109- // potentially violating MMU specs for some time thereafter.
90+ // the oldest entry, thus potentially violating MMU specs for
91+ // some time thereafter.
11092
111- G1MMUTrackerQueueElem _array[QueueLength];
112- int _head_index;
113- int _tail_index;
114- int _no_entries;
93+ G1MMUTrackerElem _array[QueueLength];
94+ int _head_index;
95+ int _tail_index;
96+ int _no_entries;
11597
11698 inline int trim_index (int index) {
11799 return (index + QueueLength) % QueueLength;
@@ -121,11 +103,19 @@ class G1MMUTrackerQueue: public G1MMUTracker {
121103 double calculate_gc_time (double current_time);
122104
123105public:
124- G1MMUTrackerQueue (double time_slice, double max_gc_time);
106+ G1MMUTracker (double time_slice, double max_gc_time);
107+
108+ void add_pause (double start, double end);
125109
126- virtual void add_pause (double start , double end );
110+ double when_sec (double current_time , double pause_time );
127111
128- virtual double when_sec (double current_time, double pause_time);
112+ double max_gc_time () const {
113+ return _max_gc_time;
114+ }
115+
116+ double when_max_gc_sec (double current_time) {
117+ return when_sec (current_time, max_gc_time ());
118+ }
129119};
130120
131121#endif // SHARE_GC_G1_G1MMUTRACKER_HPP
0 commit comments