Mon, 09 Mar 2009 13:28:46 -0700
6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair
1 /*
2 * Copyright 2001-2009 Sun Microsystems, Inc. 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 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 */
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.
28 /***** ALL TIMES ARE IN SECS!!!!!!! *****/
30 // this is the "interface"
31 class G1MMUTracker: public CHeapObj {
32 protected:
33 double _time_slice;
34 double _max_gc_time; // this is per time slice
36 double _conc_overhead_time_sec;
38 public:
39 G1MMUTracker(double time_slice, double max_gc_time);
41 void update_conc_overhead(double conc_overhead);
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;
47 double max_gc_time() {
48 return _max_gc_time - _conc_overhead_time_sec;
49 }
51 inline bool now_max_gc(double current_time) {
52 return when_sec(current_time, max_gc_time()) < 0.00001;
53 }
55 inline double when_max_gc_sec(double current_time) {
56 return when_sec(current_time, max_gc_time());
57 }
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 }
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 };
70 class G1MMUTrackerQueueElem VALUE_OBJ_CLASS_SPEC {
71 private:
72 double _start_time;
73 double _end_time;
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; }
80 G1MMUTrackerQueueElem() {
81 _start_time = 0.0;
82 _end_time = 0.0;
83 }
85 G1MMUTrackerQueueElem(double start_time, double end_time) {
86 _start_time = start_time;
87 _end_time = end_time;
88 }
89 };
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 };
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.
108 G1MMUTrackerQueueElem _array[QueueLength];
109 int _head_index;
110 int _tail_index;
111 int _no_entries;
113 inline int trim_index(int index) {
114 return (index + QueueLength) % QueueLength;
115 }
117 void remove_expired_entries(double current_time);
118 double calculate_gc_time(double current_time);
120 double longest_pause_internal(double current_time);
121 double when_internal(double current_time, double pause_time);
123 public:
124 G1MMUTrackerQueue(double time_slice, double max_gc_time);
126 virtual void add_pause(double start, double end, bool gc_thread);
128 virtual double longest_pause(double current_time);
129 virtual double when_sec(double current_time, double pause_time);
130 };