Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/g1MMUTracker.hpp @ 677:96b229c54d1e
6543938: G1: remove the concept of popularity
Reviewed-by: iveresov, tonyp
author | apetrusenko |
---|---|
date | Wed, 25 Mar 2009 13:10:54 -0700 |
parents | 0fbdb4381b99 |
children | e1fdf4fd34dc |
rev | line source |
---|---|
342 | 1 /* |
579 | 2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. |
342 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // Keeps track of the GC work and decides when it is OK to do GC work | |
26 // and for how long so that the MMU invariants are maintained. | |
27 | |
28 /***** ALL TIMES ARE IN SECS!!!!!!! *****/ | |
29 | |
30 // this is the "interface" | |
549
fe3d7c11b4b7
6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents:
342
diff
changeset
|
31 class G1MMUTracker: public CHeapObj { |
342 | 32 protected: |
33 double _time_slice; | |
34 double _max_gc_time; // this is per time slice | |
35 | |
36 double _conc_overhead_time_sec; | |
37 | |
38 public: | |
39 G1MMUTracker(double time_slice, double max_gc_time); | |
40 | |
41 void update_conc_overhead(double conc_overhead); | |
42 | |
43 virtual void add_pause(double start, double end, bool gc_thread) = 0; | |
44 virtual double longest_pause(double current_time) = 0; | |
45 virtual double when_sec(double current_time, double pause_time) = 0; | |
46 | |
47 double max_gc_time() { | |
48 return _max_gc_time - _conc_overhead_time_sec; | |
49 } | |
50 | |
51 inline bool now_max_gc(double current_time) { | |
52 return when_sec(current_time, max_gc_time()) < 0.00001; | |
53 } | |
54 | |
55 inline double when_max_gc_sec(double current_time) { | |
56 return when_sec(current_time, max_gc_time()); | |
57 } | |
58 | |
59 inline jlong when_max_gc_ms(double current_time) { | |
60 double when = when_max_gc_sec(current_time); | |
61 return (jlong) (when * 1000.0); | |
62 } | |
63 | |
64 inline jlong when_ms(double current_time, double pause_time) { | |
65 double when = when_sec(current_time, pause_time); | |
66 return (jlong) (when * 1000.0); | |
67 } | |
68 }; | |
69 | |
549
fe3d7c11b4b7
6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents:
342
diff
changeset
|
70 class G1MMUTrackerQueueElem VALUE_OBJ_CLASS_SPEC { |
342 | 71 private: |
72 double _start_time; | |
73 double _end_time; | |
74 | |
75 public: | |
76 inline double start_time() { return _start_time; } | |
77 inline double end_time() { return _end_time; } | |
78 inline double duration() { return _end_time - _start_time; } | |
79 | |
80 G1MMUTrackerQueueElem() { | |
81 _start_time = 0.0; | |
82 _end_time = 0.0; | |
83 } | |
84 | |
85 G1MMUTrackerQueueElem(double start_time, double end_time) { | |
86 _start_time = start_time; | |
87 _end_time = end_time; | |
88 } | |
89 }; | |
90 | |
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 { | |
94 private: | |
95 enum PrivateConstants { | |
96 QueueLength = 64 | |
97 }; | |
98 | |
99 // The array keeps track of all the pauses that fall within a time | |
100 // slice (the last time slice during which pauses took place). | |
101 // The data structure implemented is a circular queue. | |
102 // Head "points" to the most recent addition, tail to the oldest one. | |
103 // The array is of fixed size and I don't think we'll need more than | |
104 // two or three entries with the current behaviour of G1 pauses. | |
105 // If the array is full, an easy fix is to look for the pauses with | |
106 // the shortest gap between them and concolidate them. | |
107 | |
108 G1MMUTrackerQueueElem _array[QueueLength]; | |
109 int _head_index; | |
110 int _tail_index; | |
111 int _no_entries; | |
112 | |
113 inline int trim_index(int index) { | |
114 return (index + QueueLength) % QueueLength; | |
115 } | |
116 | |
117 void remove_expired_entries(double current_time); | |
118 double calculate_gc_time(double current_time); | |
119 | |
120 double longest_pause_internal(double current_time); | |
121 double when_internal(double current_time, double pause_time); | |
122 | |
123 public: | |
124 G1MMUTrackerQueue(double time_slice, double max_gc_time); | |
125 | |
126 virtual void add_pause(double start, double end, bool gc_thread); | |
127 | |
128 virtual double longest_pause(double current_time); | |
129 virtual double when_sec(double current_time, double pause_time); | |
130 }; |